sock_diag: don't broadcast kernel sockets
Subsystems (3)
PATCH 1/1 sock_diag: don't broadcast kernel sockets
Kernel sockets do not hold a reference for the network namespace to which they point. Socket destruction broadcasting relies on the network namespace and will cause the splat below when a kernel socket is destroyed.
This fix simply ignores kernel sockets when they are destroyed.
Reported as:
general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC CPU: 1 PID: 9130 Comm: kworker/1:1 Not tainted 4.1.0-gelk-debug+ #1 Workqueue: sock_diag_events sock_diag_broadcast_destroy_work Stack: ffff8800b9c586c0 ffff8800b9c586c0 ffff8800ac4692c0 ffff8800936d4a90 ffff8800352efd38 ffffffff8469a93e ffff8800352efd98 ffffffffc09b9b90 ffff8800352efd78 ffff8800ac4692c0 ffff8800b9c586c0 ffff8800831b6ab8 Call Trace: [<ffffffff8469a93e>] ? mutex_unlock+0xe/0x10 [<ffffffffc09b9b90>] ? inet_diag_handler_get_info+0x110/0x1fb [inet_diag] [<ffffffff845c868d>] netlink_broadcast+0x1d/0x20 [<ffffffff8469a93e>] ? mutex_unlock+0xe/0x10 [<ffffffff845b2bf5>] sock_diag_broadcast_destroy_work+0xd5/0x160 [<ffffffff8408ea97>] process_one_work+0x147/0x420 [<ffffffff8408f0f9>] worker_thread+0x69/0x470 [<ffffffff8409fda3>] ? preempt_count_sub+0xa3/0xf0 [<ffffffff8408f090>] ? rescuer_thread+0x320/0x320 [<ffffffff84093cd7>] kthread+0x107/0x120 [<ffffffff84093bd0>] ? kthread_create_on_node+0x1b0/0x1b0 [<ffffffff8469d31f>] ret_from_fork+0x3f/0x70 [<ffffffff84093bd0>] ? kthread_create_on_node+0x1b0/0x1b0
Tested:
Using a debug kernel while 'ss -E' is running:
ip netns add test-ns
ip netns delete test-ns
netns of kernel sockets.
--- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/sock.c +1 -1
@@ -1454,7 +1454,7 @@ void sk_destruct(struct sock *sk)static void __sk_free (struct sock *sk) { -if (unlikely (sock_diag_has_destroy_listeners (sk))) +if (unlikely (sock_diag_has_destroy_listeners (sk) && sk->sk_net_refcnt))sock_diag_broadcast_destroy (sk);else sk_destruct (sk);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
From: Craig Gallek <[email protected]>
Date: Tue, 30 Jun 2015 12:49:32 -0400
Quoted 6 lines
Kernel sockets do not hold a reference for the network namespace to which they point. Socket destruction broadcasting relies on the network namespace and will cause the splat below when a kernel socket is destroyed.
This fix simply ignores kernel sockets when they are destroyed.
...
Quoted 5 lines
Tested:
Using a debug kernel while 'ss -E' is running:
ip netns add test-ns
ip netns delete test-ns
Quoted 7 lines
Fixes eb4cb008529c sock_diag: define destruction multicast groupsFixes 26abe14379f8 net: Modify sk_alloc to not reference count thenetns of kernel sockets.
Reported-by Dave Jones <[email protected]>Suggested-by Eric Dumazet <[email protected]>Signed-off-by Craig Gallek <[email protected]>
APplied, thanks.