Skip to contentSkip to conversation

l2tp: Fix PPP header erasure and memory leak

PATCH Applied Guillaume Nault 3 participants 6 messages Jun 12, 2013 – Jun 13, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 l2tp: Fix PPP header erasure and memory leak

Copy user data after PPP framing header. This prevents erasure of the added PPP header and avoids leaking two bytes of uninitialised memory at the end of skb's data buffer.

---
 net/l2tp/l2tp_ppp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/l2tp/l2tp_ppp.c +2 -2
index 637a341..681c626 100644
@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
 	skb_put(skb, 2);
 
 	/* Copy user data into skb */
-	error = memcpy_fromiovec(skb->data, m->msg_iov, total_len);
+	error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
+				 total_len);
 	if (error < 0) {
 		kfree_skb(skb);
 		goto error_put_sess_tun;
 	}
-	skb_put(skb, total_len);
 
 	l2tp_xmit_skb(session, skb, session->hdr_len);
 
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 18 lines · Guillaume Nault

Copy user data after PPP framing header. This prevents erasure of the added PPP header and avoids leaking two bytes of uninitialised memory at the end of skb's data buffer.

---
 net/l2tp/l2tp_ppp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/l2tp/l2tp_ppp.c +0 -1
index 637a341..681c626 100644
@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
 	skb_put(skb, 2);
 
 	/* Copy user data into skb */
-	error = memcpy_fromiovec(skb->data, m->msg_iov, total_len);

net/l2tp/l2tp_ppp.c static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh · line 357

Quoted 10 lines
net/l2tp/l2tp_ppp.c +2 -1
+	error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
+				 total_len);
 	if (error < 0) {
 		kfree_skb(skb);
 		goto error_put_sess_tun;
 	}
-	skb_put(skb, total_len);
 
 	l2tp_xmit_skb(session, skb, session->hdr_len);
 

I see no real change in your patch.

skb_put(skb, X) returns skb->data before the put operation.

Could you elaborate ?

#3 lore raw
Quoted 27 lines · Eric Dumazet
Quoted 26 lines · Guillaume Nault

Copy user data after PPP framing header. This prevents erasure of the added PPP header and avoids leaking two bytes of uninitialised memory at the end of skb's data buffer.

---
 net/l2tp/l2tp_ppp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/l2tp/l2tp_ppp.c +2 -2
index 637a341..681c626 100644
@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
 	skb_put(skb, 2);
 
 	/* Copy user data into skb */
-	error = memcpy_fromiovec(skb->data, m->msg_iov, total_len);
+	error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
+				 total_len);
 	if (error < 0) {
 		kfree_skb(skb);
 		goto error_put_sess_tun;
 	}
-	skb_put(skb, total_len);
 
Quoted 8 lines

net/l2tp/l2tp_ppp.c static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh · line 357

Quoted 2 lines
net/l2tp/l2tp_ppp.c +0 -0
 	l2tp_xmit_skb(session, skb, session->hdr_len);
 

I see no real change in your patch.

skb_put(skb, X) returns skb->data before the put operation.

Could you elaborate ?

Oh well, I missed the prior skb_put(skb, 2), nevermind

#5 lore raw

PATCH 2/2 l2tp: Fix sendmsg() return value

In reply to a message not in the archive

PPPoL2TP sockets should comply with the standard send*() return values (i.e. return number of bytes sent instead of 0 upon success).

---
 net/l2tp/l2tp_ppp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_ppp.c +1 -1
index 681c626..8dec687 100644
@@ -358,7 +358,7 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
 	sock_put(ps->tunnel_sock);
 	sock_put(sk);
 
-	return error;
+	return total_len;
 
 error_put_sess_tun:
 	sock_put(ps->tunnel_sock);
Signature · 1 line
1.7.10.4
maintainer Applied
#6 lore raw

Re: [PATCH net,stable 2/2] l2tp: Fix sendmsg() return value

From: Guillaume Nault <[email protected]>
Date: Wed, 12 Jun 2013 16:07:36 +0200

Quoted 4 lines

PPPoL2TP sockets should comply with the standard send*() return values (i.e. return number of bytes sent instead of 0 upon success).

Applied.