Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp403868pxb; Wed, 3 Mar 2021 06:18:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQY2JLBl2wUVuEtddIgnRNFKXrQNNcIDyOWmcymxfENijd4wvh45cU/2pzREOe0eflb/V6 X-Received: by 2002:a17:906:4f10:: with SMTP id t16mr26020777eju.531.1614781124834; Wed, 03 Mar 2021 06:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781124; cv=none; d=google.com; s=arc-20160816; b=GI6fM05deBOQih6IvwO6UM/+0kQ8esO31KrkXZ902Tw0cpKAdSAh/nQxEgTWlnYk27 wPUQLhA/z1I/DcZpwmsZuBDTsDUnW54pMZOalvsA2uIfbQMs6KI3U4bY0B0V1j81a2Sj n+ufRrmPJuT6w1wWkCgFa/9OW7RwoPi9uKvXDlBxwlxfPuNHrpDdSbBo+YQ2Ca5a2Zy9 mfby6a0RWUQYSDu/fCbzRrV5EW67tS0pzw8ujRWdgrtPETgri+VAxO9fOJO5wnTzSd6q 6lhRe78pCY/iWIviI6q0pR4JZ7iVKzqTPILVXlrrhPiBGrttn7jrdcs/OzhIHitOAPWX mWRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EIlKkRN+zQC2aVrrw5qFJEZWojhlgTG4yUa87X+cZ34=; b=RMCTSdUS5Gkb1TDPA05rkpJWwDNIxT0Hdv12ALyo0wAe25ulPEYjOoePZNZwli9TfC +bNS1MFCX2gvOMVzvo4Zc8PpgiujSI6OjkX183d02o9qd1UUzafsy2AKdtVkWyfDzgtl cpV+v1X/GCphKv8E1NETr3V2oVJgyLrEQ4I8j4BRM1gftZNBlH+xh9iMNeC/1bNRu/Fc qx9aXiWqBOJC77YljTRQUlBXnw6UJO8lBpbICzH4DG3PXcUcFMydAJHt7/HE+qpyKyXw lswVKA8kapsHxmzFF8nJKtWmYWxi6+IuRxn6M/A8WF07/AofExghhGm6zotmOQLM+U95 6nkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UsMlxAL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e13si14487617eds.140.2021.03.03.06.18.11; Wed, 03 Mar 2021 06:18:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UsMlxAL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243784AbhCAVBL (ORCPT + 99 others); Mon, 1 Mar 2021 16:01:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:37624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237310AbhCARLR (ORCPT ); Mon, 1 Mar 2021 12:11:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73F1364EE1; Mon, 1 Mar 2021 16:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617003; bh=Ib6teQuHjB9HzCXjnaxJjSzlYoBEoIzfyIQYvIjCJuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsMlxAL7wdwanA0t5JNsITT5mTAV44vT1zkWqL7Hfqv8zVcKS2je0XWgFO+fErnIy bFDYTFao4YM+wFeB6o9wWfhKmKQr8++tsCXuiOt8/YMU3fcKmcLr1gngzx0AhhMAzF wYn4qQoxdRmRxvn+QhUG6GaogyOpjDVtXULu3YVs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 169/247] vxlan: move debug check after netdev unregister Date: Mon, 1 Mar 2021 17:13:09 +0100 Message-Id: <20210301161039.933197289@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Taehee Yoo [ Upstream commit 92584ddf550ae72d492858c19d1f9025e07a9350 ] The debug check must be done after unregister_netdevice_many() call -- the hlist_del_rcu() for this is done inside .ndo_stop. This is the same with commit 0fda7600c2e1 ("geneve: move debug check after netdev unregister") Test commands: ip netns del A ip netns add A ip netns add B ip netns exec B ip link add vxlan0 type vxlan vni 100 local 10.0.0.1 \ remote 10.0.0.2 dstport 4789 srcport 4789 4789 ip netns exec B ip link set vxlan0 netns A ip netns exec A ip link set vxlan0 up ip netns del B Splat looks like: [ 73.176249][ T7] ------------[ cut here ]------------ [ 73.178662][ T7] WARNING: CPU: 4 PID: 7 at drivers/net/vxlan.c:4743 vxlan_exit_batch_net+0x52e/0x720 [vxlan] [ 73.182597][ T7] Modules linked in: vxlan openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 mlx5_core nfp mlxfw ixgbevf tls sch_fq_codel nf_tables nfnetlink ip_tables x_tables unix [ 73.190113][ T7] CPU: 4 PID: 7 Comm: kworker/u16:0 Not tainted 5.11.0-rc7+ #838 [ 73.193037][ T7] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 73.196986][ T7] Workqueue: netns cleanup_net [ 73.198946][ T7] RIP: 0010:vxlan_exit_batch_net+0x52e/0x720 [vxlan] [ 73.201509][ T7] Code: 00 01 00 00 0f 84 39 fd ff ff 48 89 ca 48 c1 ea 03 80 3c 1a 00 0f 85 a6 00 00 00 89 c2 48 83 c2 02 49 8b 14 d4 48 85 d2 74 ce <0f> 0b eb ca e8 b9 51 db dd 84 c0 0f 85 4a fe ff ff 48 c7 c2 80 bc [ 73.208813][ T7] RSP: 0018:ffff888100907c10 EFLAGS: 00010286 [ 73.211027][ T7] RAX: 000000000000003c RBX: dffffc0000000000 RCX: ffff88800ec411f0 [ 73.213702][ T7] RDX: ffff88800a278000 RSI: ffff88800fc78c70 RDI: ffff88800fc78070 [ 73.216169][ T7] RBP: ffff88800b5cbdc0 R08: fffffbfff424de61 R09: fffffbfff424de61 [ 73.218463][ T7] R10: ffffffffa126f307 R11: fffffbfff424de60 R12: ffff88800ec41000 [ 73.220794][ T7] R13: ffff888100907d08 R14: ffff888100907c50 R15: ffff88800fc78c40 [ 73.223337][ T7] FS: 0000000000000000(0000) GS:ffff888114800000(0000) knlGS:0000000000000000 [ 73.225814][ T7] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 73.227616][ T7] CR2: 0000562b5cb4f4d0 CR3: 0000000105fbe001 CR4: 00000000003706e0 [ 73.229700][ T7] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 73.231820][ T7] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 73.233844][ T7] Call Trace: [ 73.234698][ T7] ? vxlan_err_lookup+0x3c0/0x3c0 [vxlan] [ 73.235962][ T7] ? ops_exit_list.isra.11+0x93/0x140 [ 73.237134][ T7] cleanup_net+0x45e/0x8a0 [ ... ] Fixes: 57b61127ab7d ("vxlan: speedup vxlan tunnels dismantle") Signed-off-by: Taehee Yoo Link: https://lore.kernel.org/r/20210221154552.11749-1-ap420073@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/vxlan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 66fffbd64a33f..49e8c6d42cda4 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -3812,7 +3812,6 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) struct vxlan_net *vn = net_generic(net, vxlan_net_id); struct vxlan_dev *vxlan, *next; struct net_device *dev, *aux; - unsigned int h; for_each_netdev_safe(net, dev, aux) if (dev->rtnl_link_ops == &vxlan_link_ops) @@ -3826,14 +3825,13 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) unregister_netdevice_queue(vxlan->dev, head); } - for (h = 0; h < PORT_HASH_SIZE; ++h) - WARN_ON_ONCE(!hlist_empty(&vn->sock_list[h])); } static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) { struct net *net; LIST_HEAD(list); + unsigned int h; rtnl_lock(); list_for_each_entry(net, net_list, exit_list) @@ -3841,6 +3839,13 @@ static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) unregister_netdevice_many(&list); rtnl_unlock(); + + list_for_each_entry(net, net_list, exit_list) { + struct vxlan_net *vn = net_generic(net, vxlan_net_id); + + for (h = 0; h < PORT_HASH_SIZE; ++h) + WARN_ON_ONCE(!hlist_empty(&vn->sock_list[h])); + } } static struct pernet_operations vxlan_net_ops = { -- 2.27.0