• Craig Gallek's avatar
    sock_diag: don't broadcast kernel sockets · b922622e
    Craig Gallek authored
    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
    
    Fixes: eb4cb008 sock_diag: define destruction multicast groups
    Fixes: 26abe143 net: Modify sk_alloc to not reference count the
      netns of kernel sockets.
    Reported-by: default avatarDave Jones <davej@codemonkey.org.uk>
    Suggested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
    Signed-off-by: default avatarCraig Gallek <kraig@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b922622e
sock.c 72.7 KB