l2tp: Fix PPP header erasure and memory leak
Subsystems (2)
PATCH 1/2 l2tp: Fix PPP header erasure and memory leak
In reply to a message not in the archiveCopy 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
@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghskb_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
PATCH 2/2 l2tp: Fix sendmsg() return value
In reply to a message not in the archivePPPoL2TP 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
@@ -358,7 +358,7 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghsock_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
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.
Signed-off-by Guillaume Nault <[email protected]>--- net/l2tp/l2tp_ppp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/l2tp/l2tp_ppp.c +0
-1@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghskb_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 ?
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.
Signed-off-by Guillaume Nault <[email protected]>--- net/l2tp/l2tp_ppp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/l2tp/l2tp_ppp.c +2
-2@@ -346,12 +346,12 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghskb_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
-0l2tp_xmit_skb (session, skb, session->hdr_len);I see no real change in your patch.
skb_put(skb, X)returnsskb->databefore the put operation.Could you elaborate ?
Oh well, I missed the prior skb_put(skb, 2), nevermind
From: Guillaume Nault <[email protected]>
Date: Wed, 12 Jun 2013 16:07:23 +0200
Quoted 5 lines
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.
Signed-off-by Guillaume Nault <[email protected]>
Applied.
Re: [PATCH net,stable 2/2] l2tp: Fix sendmsg() return value
In reply to Guillaume NaultFrom: 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).
Signed-off-by Guillaume Nault <[email protected]>
Applied.