Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73258
b: refs/heads/master
c: 9178100
h: refs/heads/master
v: v3
  • Loading branch information
James Chapman authored and David S. Miller committed Nov 7, 2007
1 parent 1696e34 commit 712a807
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6a9fb9479f2672fa392711735de9e642395c9a14
refs/heads/master: 91781004b9c029ee55b7aa9ef950a373ba865dc6
25 changes: 18 additions & 7 deletions trunk/drivers/net/pppol2tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,15 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
{
struct pppol2tp_session *session = NULL;
struct pppol2tp_tunnel *tunnel;
unsigned char *ptr;
unsigned char *ptr, *optr;
u16 hdrflags;
u16 tunnel_id, session_id;
int length;
int offset;

tunnel = pppol2tp_sock_to_tunnel(sock);
if (tunnel == NULL)
goto error;
goto no_tunnel;

/* UDP always verifies the packet length. */
__skb_pull(skb, sizeof(struct udphdr));
Expand All @@ -509,7 +509,7 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
}

/* Point to L2TP header */
ptr = skb->data;
optr = ptr = skb->data;

/* Get L2TP header flags */
hdrflags = ntohs(*(__be16*)ptr);
Expand Down Expand Up @@ -637,12 +637,14 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
/* If offset bit set, skip it. */
if (hdrflags & L2TP_HDRFLAG_O) {
offset = ntohs(*(__be16 *)ptr);
skb->transport_header += 2 + offset;
if (!pskb_may_pull(skb, skb_transport_offset(skb) + 2))
goto discard;
ptr += 2 + offset;
}

__skb_pull(skb, skb_transport_offset(skb));
offset = ptr - optr;
if (!pskb_may_pull(skb, offset))
goto discard;

__skb_pull(skb, offset);

/* Skip PPP header, if present. In testing, Microsoft L2TP clients
* don't send the PPP header (PPP header compression enabled), but
Expand All @@ -652,6 +654,9 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
* Note that skb->data[] isn't dereferenced from a u16 ptr here since
* the field may be unaligned.
*/
if (!pskb_may_pull(skb, 2))
goto discard;

if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03))
skb_pull(skb, 2);

Expand Down Expand Up @@ -709,6 +714,10 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
return 0;

error:
/* Put UDP header back */
__skb_push(skb, sizeof(struct udphdr));

no_tunnel:
return 1;
}

Expand Down Expand Up @@ -1050,6 +1059,8 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
/* Get routing info from the tunnel socket */
dst_release(skb->dst);
skb->dst = sk_dst_get(sk_tun);
skb_orphan(skb);
skb->sk = sk_tun;

/* Queue the packet to IP for output */
len = skb->len;
Expand Down

0 comments on commit 712a807

Please sign in to comment.