From patchwork Thu Aug 14 09:12:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 35393 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 110CC203C5 for ; Thu, 14 Aug 2014 09:13:56 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf7013291pac.7 for ; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=k3mVNSKT9g8VX1q+NLqETFqy2A01f0kBBNfEojC+/QQ=; b=YfN/c/5+9kEdEv30/E8fDxcGSr0TudYOS6NzewD5rhArH+w9T+A6cZk1rvmJ5MqtKB LA9t8IKgbFw+91SxgWuyu2D4fj69kSgotlSvk8ijlSSBBrFOKMaxBxkfojw80PorU5yG 5Nn4ein59s6jgFJSZryrSRev+XSZe9OJHfpuhUIefPyXDW7xMRfLWriehQsqtgNrQjTn BQN4f4z9YCmvJHXbYnC3Lgh3rc9wpyPTnm/wi0JInbPF8AZsexv5/f/2c4cM6kN4ZZ2H I6p2394Ilmp2T945m2CAZuKYbM2R1jFDiPzfn+8Uo6FgbqPD4IIDDekWDU7Q8oftQpR1 vavQ== X-Gm-Message-State: ALoCoQnFo14OP/mEgeJ59whCcP7643k0QTFNp4qALG+RB25SSqpkB8LHmW63lXi3G7CURHN55mbD X-Received: by 10.66.141.70 with SMTP id rm6mr627805pab.37.1408007636394; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.228 with SMTP id 91ls673797qgr.70.gmail; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) X-Received: by 10.220.167.9 with SMTP id o9mr2615215vcy.8.1408007636239; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id ga4si2295831vdc.38.2014.08.14.02.13.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Aug 2014 02:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so1061090vcb.13 for ; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr2622758vcn.16.1408007636152; Thu, 14 Aug 2014 02:13:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp18116vcb; Thu, 14 Aug 2014 02:13:55 -0700 (PDT) X-Received: by 10.69.18.11 with SMTP id gi11mr595816pbd.163.1408007635016; Thu, 14 Aug 2014 02:13:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wo9si3581329pbc.214.2014.08.14.02.13.54 for ; Thu, 14 Aug 2014 02:13:55 -0700 (PDT) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbaHNJNv (ORCPT + 3 others); Thu, 14 Aug 2014 05:13:51 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:5243 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750795AbaHNJNs (ORCPT ); Thu, 14 Aug 2014 05:13:48 -0400 Received: from 172.24.2.119 (EHLO szxeml460-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BYE25768; Thu, 14 Aug 2014 17:13:35 +0800 (CST) Received: from [127.0.0.1] (10.177.22.246) by szxeml460-hub.china.huawei.com (10.82.67.203) with Microsoft SMTP Server id 14.3.158.1; Thu, 14 Aug 2014 17:13:29 +0800 Message-ID: <53EC7D8C.6060908@huawei.com> Date: Thu, 14 Aug 2014 17:12:44 +0800 From: Ding Tianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: "Keller, Jacob E" , Cong Wang , "David S. Miller" , "Patrick McHardy" , Netdev Subject: [PATCH net] macvlan: Fix the bug when destroy macvlan dev port X-Originating-IP: [10.177.22.246] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dingtianhong@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The bug was reported by Keller.Jacob E, and introduced by commit a188a54d1162 ("macvlan: simplify the structure port") -------------------------------------------------------------------------- [ 80.643286] BUG: unable to handle kernel NULL pointer dereference at 0000000000000878 [ 80.670103] IP: [] try_to_grab_pending+0x64/0x1f0 [ 80.691289] PGD 22c102067 PUD 235bf0067 PMD 0 [ 80.706611] Oops: 0002 [#1] SMP [ 80.717836] Modules linked in: macvlan nfsd lockd nfs_acl exportfs auth_rpcgss sunrpc oid_registry ioatdma ixgbe(-) mdio igb dca [ 80.757935] CPU: 37 PID: 6724 Comm: rmmod Not tainted 3.16.0-net-next-08-12-2014-FCoE+ #1 [ 80.785688] Hardware name: Intel Corporation S2600CO/S2600CO, BIOS SE5C600.86B.02.03.0003.041920141333 04/19/2014 [ 80.820310] task: ffff880235a9eae0 ti: ffff88022e844000 task.ti: ffff88022e844000 [ 80.845770] RIP: 0010:[] [] try_to_grab_pending+0x64/0x1f0 [ 80.875326] RSP: 0018:ffff88022e847b28 EFLAGS: 00010046 [ 80.893251] RAX: 0000000000037a6a RBX: 0000000000000878 RCX: 0000000000000000 [ 80.917187] RDX: ffff880235a9eae0 RSI: 0000000000000001 RDI: ffffffff810832db [ 80.941125] RBP: ffff88022e847b58 R08: 0000000000000000 R09: 0000000000000000 [ 80.965056] R10: 0000000000000001 R11: 0000000000000001 R12: ffff88022e847b70 [ 80.988994] R13: 0000000000000000 R14: ffff88022e847be8 R15: ffffffff81ebe440 [ 81.012929] FS: 00007fab90b07700(0000) GS:ffff88043f7a0000(0000) knlGS:0000000000000000 [ 81.040400] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 81.059757] CR2: 0000000000000878 CR3: 0000000235a42000 CR4: 00000000001407e0 [ 81.083689] Stack: [ 81.090739] ffff880235a9eae0 0000000000000878 ffff88022e847b70 0000000000000000 [ 81.116253] ffff88022e847be8 ffffffff81ebe440 ffff88022e847b98 ffffffff810847f1 [ 81.141766] ffff88022e847b78 0000000000000286 ffff880234200000 0000000000000000 [ 81.167282] Call Trace: [ 81.175768] [] __cancel_work_timer+0x31/0x170 [ 81.195985] [] cancel_work_sync+0xb/0x10 [ 81.214769] [] macvlan_port_destroy+0x28/0x60 [macvlan] [ 81.237844] [] macvlan_uninit+0x40/0x50 [macvlan] [ 81.259209] [] rollback_registered_many+0x1a2/0x2c0 [ 81.281140] [] unregister_netdevice_many+0x1a/0xb0 [ 81.302786] [] macvlan_device_event+0x1ef/0x240 [macvlan] [ 81.326439] [] notifier_call_chain+0x4d/0x70 [ 81.346366] [] raw_notifier_call_chain+0x11/0x20 [ 81.367439] [] call_netdevice_notifiers_info+0x3b/0x70 [ 81.390228] [] call_netdevice_notifiers+0x11/0x20 [ 81.411587] [] rollback_registered_many+0x17d/0x2c0 [ 81.433518] [] unregister_netdevice_queue+0x75/0x110 [ 81.455735] [] unregister_netdev+0x1b/0x30 [ 81.475094] [] ixgbe_remove+0x170/0x1d0 [ixgbe] [ 81.495886] [] pci_device_remove+0x32/0x60 [ 81.515246] [] __device_release_driver+0x64/0xd0 [ 81.536321] [] driver_detach+0xc8/0xd0 [ 81.554530] [] bus_remove_driver+0x4e/0xa0 [ 81.573888] [] driver_unregister+0x2b/0x60 [ 81.593246] [] pci_unregister_driver+0x1e/0xa0 [ 81.613749] [] ixgbe_exit_module+0x1c/0x2e [ixgbe] [ 81.635401] [] SyS_delete_module+0x15b/0x1e0 [ 81.655334] [] ? sysret_check+0x22/0x5d [ 81.673833] [] ? trace_hardirqs_on_caller+0x11d/0x1e0 [ 81.696339] [] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 81.717985] [] system_call_fastpath+0x16/0x1b [ 81.738199] Code: 00 48 83 3d 6e bb da 00 00 48 89 c2 0f 84 67 01 00 00 fa 66 0f 1f 44 00 00 49 89 14 24 e8 b5 4b 02 00 45 84 ed 0f 85 ac 00 00 00 0f ba 2b 00 72 1d 31 c0 48 8b 5d d8 4c 8b 65 e0 4c 8b 6d e8 [ 81.807026] RIP [] try_to_grab_pending+0x64/0x1f0 [ 81.828468] RSP [ 81.840384] CR2: 0000000000000878 [ 81.851731] ---[ end trace 9f6c7232e3464e11 ]--- ------------------------------------------------------------ This bug could be triggered by these steps: modprobe ixgbe ; modprobe macvlan ip link add link p96p1 address 00:1B:21:6E:06:00 macvlan0 type macvlan ip link add link p96p1 address 00:1B:21:6E:06:01 macvlan1 type macvlan ip link add link p96p1 address 00:1B:21:6E:06:02 macvlan2 type macvlan ip link add link p96p1 address 00:1B:21:6E:06:03 macvlan3 type macvlan rmmod ixgbe The reason is that when remove the ixgbe driver, the macvlan_uninit will be called multiple because the lowerdev is being destroyed, but at the first calling of macvlan_uninit, the port for the macvlan has been destroyed, so when the other macvlan_uninit entered, the port is not exist and panic was happened. To fix this problem, we need to check whether the port is exist when calling macvlan_port_destroy(), do nothing if the port has been destroyed yet. Reported-by: "Keller, Jacob E" Signed-off-by: Ding Tianhong --- drivers/net/macvlan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index ef8a5c2..182f31b 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -933,6 +933,9 @@ static void macvlan_port_destroy(struct net_device *dev) { struct macvlan_port *port = macvlan_port_get_rtnl(dev); + if (!macvlan_port_exists(dev)) + return; + cancel_work_sync(&port->bc_work); dev->priv_flags &= ~IFF_MACVLAN_PORT; netdev_rx_handler_unregister(dev);