[PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

STALE6652d

5 messages, 2 authors, 2008-06-04 · open the first message on its own page

[PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

From: James Chapman <jchapman@katalix.com>
Date: 2008-06-04 20:56:49

If an L2TP daemon closes a tunnel socket while packets are queued in
the tunnel's reorder queue, a kernel warning is logged because the
socket is closed while skbs are still referencing it. The fix is to
purge the queue in the socket's release handler.

WARNING: at include/net/sock.h:351 udp_lib_unhash+0x41/0x68()
Pid: 12998, comm: openl2tpd Not tainted 2.6.25 #8
 [<c0423c58>] warn_on_slowpath+0x41/0x51
 [<c05d33a7>] udp_lib_unhash+0x41/0x68
 [<c059424d>] sk_common_release+0x23/0x90
 [<c05d16be>] udp_lib_close+0x8/0xa
 [<c05d8684>] inet_release+0x42/0x48
 [<c0592599>] sock_release+0x14/0x60
 [<c059299f>] sock_close+0x29/0x30
 [<c046ef52>] __fput+0xad/0x15b
 [<c046f1d9>] fput+0x17/0x19
 [<c046c8c4>] filp_close+0x50/0x5a
 [<c046da06>] sys_close+0x69/0x9f
 [<c04048ce>] syscall_call+0x7/0xb

Signed-off-by: James Chapman <jchapman@katalix.com> 

Index: linux-2.6.25/drivers/net/pppol2tp.c
===================================================================
--- linux-2.6.25.orig/drivers/net/pppol2tp.c
+++ linux-2.6.25/drivers/net/pppol2tp.c
@@ -1318,6 +1318,7 @@ out:
 static int pppol2tp_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
+	struct pppol2tp_session *session;
 	int error;
 
 	if (!sk)
@@ -1335,9 +1336,18 @@ static int pppol2tp_release(struct socke
 	sock_orphan(sk);
 	sock->sk = NULL;
 
+	session = pppol2tp_sock_to_session(sk);
+
 	/* Purge any queued data */
 	skb_queue_purge(&sk->sk_receive_queue);
 	skb_queue_purge(&sk->sk_write_queue);
+	if (session != NULL) {
+		struct sk_buff *skb;
+		while ((skb = skb_dequeue(&session->reorder_q))) {
+			kfree_skb(skb);
+			sock_put(sk);
+		}
+	}
 
 	release_sock(sk);
 

Re: [PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

From: David Miller <davem@davemloft.net>
Date: 2008-06-04 22:08:36

From: James Chapman <jchapman@katalix.com>
Date: Wed, 4 Jun 2008 21:56:44 +0100
If an L2TP daemon closes a tunnel socket while packets are queued in
the tunnel's reorder queue, a kernel warning is logged because the
socket is closed while skbs are still referencing it. The fix is to
purge the queue in the socket's release handler.

WARNING: at include/net/sock.h:351 udp_lib_unhash+0x41/0x68()
Pid: 12998, comm: openl2tpd Not tainted 2.6.25 #8
 [<c0423c58>] warn_on_slowpath+0x41/0x51
 [<c05d33a7>] udp_lib_unhash+0x41/0x68
 [<c059424d>] sk_common_release+0x23/0x90
 [<c05d16be>] udp_lib_close+0x8/0xa
 [<c05d8684>] inet_release+0x42/0x48
 [<c0592599>] sock_release+0x14/0x60
 [<c059299f>] sock_close+0x29/0x30
 [<c046ef52>] __fput+0xad/0x15b
 [<c046f1d9>] fput+0x17/0x19
 [<c046c8c4>] filp_close+0x50/0x5a
 [<c046da06>] sys_close+0x69/0x9f
 [<c04048ce>] syscall_call+0x7/0xb

Signed-off-by: James Chapman <jchapman@katalix.com> 
Applied, thanks.

Re: [PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

From: David Miller <davem@davemloft.net>
Date: 2008-06-04 22:11:49

From: David Miller <davem@davemloft.net>
Date: Wed, 04 Jun 2008 15:08:35 -0700 (PDT)
Applied, thanks.
James your second patch doesn't apply cleanly:
@@ -1066,7 +1100,7 @@ static int pppol2tp_xmit(struct ppp_chan
 	dst_release(skb->dst);
 	skb->dst = dst_clone(__sk_dst_get(sk_tun));
 	skb_orphan(skb);
-	skb->sk = sk_tun;
+	pppol2tp_skb_set_owner_w(skb, sk_tun);
 
 	/* Queue the packet to IP for output */
 	len = skb->len;
There is no skb_orphan() call in the current pppol2tp.c code.

Please always prepare your patches against the current tree.

Re: [PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

From: James Chapman <jchapman@katalix.com>
Date: 2008-06-04 22:33:11

David Miller wrote:
quoted hunk
From: David Miller <davem@davemloft.net>
Date: Wed, 04 Jun 2008 15:08:35 -0700 (PDT)
quoted
Applied, thanks.
James your second patch doesn't apply cleanly:
@@ -1066,7 +1100,7 @@ static int pppol2tp_xmit(struct ppp_chan
 	dst_release(skb->dst);
 	skb->dst = dst_clone(__sk_dst_get(sk_tun));
 	skb_orphan(skb);
-	skb->sk = sk_tun;
+	pppol2tp_skb_set_owner_w(skb, sk_tun);
 
 	/* Queue the packet to IP for output */
 	len = skb->len;
There is no skb_orphan() call in the current pppol2tp.c code.

Please always prepare your patches against the current tree.
My apologies. I sent the wrong patch version. The skb_orphan() call was 
moved in the truesize patch that has already been applied. Shall I resend?

-- 
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development

Re: [PATCH 1/2][L2TP]: Fix possible WARN_ON from socket code when UDP socket is closed

From: David Miller <davem@davemloft.net>
Date: 2008-06-04 22:36:41

From: James Chapman <jchapman@katalix.com>
Date: Wed, 04 Jun 2008 23:33:06 +0100
Shall I resend?
Of course.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help