From patchwork Tue Jun 30 16:49:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Gallek X-Patchwork-Id: 489769 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E637F1402C0 for ; Wed, 1 Jul 2015 02:49:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=fx9yZyIR; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121AbbF3Qtv (ORCPT ); Tue, 30 Jun 2015 12:49:51 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:36479 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbbF3Qtt (ORCPT ); Tue, 30 Jun 2015 12:49:49 -0400 Received: by qkei195 with SMTP id i195so10606951qke.3 for ; Tue, 30 Jun 2015 09:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+SHjUwRyrGPG/xFUxymMypY59zAxg43iz2hsdAJ+CRI=; b=fx9yZyIRc4qHkgxPTcGRNOpzFkQXjeOSF5APqDmW9DblBE1MlUom+nrI1/5z8rymsu GnKbdqEDRSDSdRX/SdVWCWybreUuXqZcYe3RejpYJm9x7x0UrpK10fqJl/Sdmr4cqgsw 9WXXJA39gMXvEWhFwaFy/bPF/hG+RSzTXrxKUxdlodA52VcDqpe4JefCp3UBswuS6DG3 YXUwGrMpuXkcXthSNtVNHhbzRlajQHJ0cgDZx1ay6QE8N0Vf87EtZcagfdOLPC64o9t4 7bwawGzWMRrRItafna7Iv6Fu219B8IeGMNBkK6Grm+2HHB9OuHjI7kOGF9W7krERzyOT mIPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+SHjUwRyrGPG/xFUxymMypY59zAxg43iz2hsdAJ+CRI=; b=ZFx3jluGB6zu5AZPZicADWOKYKfDqlO7HXOcLSDV74QDeTcJFW1mcFbMPRQYZUsRWd fCBQMO44Ce3wWEN7sIDTN9657sh/aZNSs2ezDu626mc+0SupWJWa7G+y8xWZHDE4nQk9 fGxARqArgeKrlcUbi/h1OmyQhO5eiq/rLgeOE0NdHqqFCrJWvqguFZLv5oemGOeAyH+9 A/Xk1IImlXrYp4RYE/ZRt5LEZxcgFiQeOgLTnO1DU4nvW+MP3p5gW7VKPfU0VE3SRtlF 5zw5dmpj/8salv2Jcd7gpytPMcYqEOWpupFZUR4QJyBLeSgYtK35DqJXw/UYGvstXNAN 4E7Q== X-Gm-Message-State: ALoCoQkzomLWmSoHYybBDopP00fG84lahQfE30xb7lcXd6KuYFQXqDAl5VTUALT9rm43O67WqHC7 X-Received: by 10.55.42.35 with SMTP id q35mr45299442qkh.46.1435682988259; Tue, 30 Jun 2015 09:49:48 -0700 (PDT) Received: from cgallek-warp18.nyc.corp.google.com ([172.26.105.104]) by mx.google.com with ESMTPSA id v64sm186549qgv.28.2015.06.30.09.49.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 09:49:47 -0700 (PDT) From: Craig Gallek To: netdev@vger.kernel.org Cc: davej@codemonkey.org.uk, edumazet@google.com, ebiederm@xmission.com, davem@davemloft.net, Craig Gallek Subject: [PATCH net] sock_diag: don't broadcast kernel sockets Date: Tue, 30 Jun 2015 12:49:32 -0400 Message-Id: <1435682972-2703-1-git-send-email-kraig@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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: [] ? mutex_unlock+0xe/0x10 [] ? inet_diag_handler_get_info+0x110/0x1fb [inet_diag] [] netlink_broadcast+0x1d/0x20 [] ? mutex_unlock+0xe/0x10 [] sock_diag_broadcast_destroy_work+0xd5/0x160 [] process_one_work+0x147/0x420 [] worker_thread+0x69/0x470 [] ? preempt_count_sub+0xa3/0xf0 [] ? rescuer_thread+0x320/0x320 [] kthread+0x107/0x120 [] ? kthread_create_on_node+0x1b0/0x1b0 [] ret_from_fork+0x3f/0x70 [] ? 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: eb4cb008529c sock_diag: define destruction multicast groups Fixes: 26abe14379f8 net: Modify sk_alloc to not reference count the netns of kernel sockets. Reported-by: Dave Jones Suggested-by: Eric Dumazet Signed-off-by: Craig Gallek --- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index e4be66f..08f16db 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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);