linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Christophe Gouault <christophe.gouault@6wind.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: [PATCH 4.19 77/95] xfrm interface: fix oops when deleting a x-netns interface
Date: Mon,  1 Jun 2020 19:54:17 +0200	[thread overview]
Message-ID: <20200601174032.556673050@linuxfoundation.org> (raw)
In-Reply-To: <20200601174020.759151073@linuxfoundation.org>

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>

commit c95c5f58b35ef995f66cb55547eee6093ab5fcb8 upstream.

Here is the steps to reproduce the problem:
ip netns add foo
ip netns add bar
ip -n foo link add xfrmi0 type xfrm dev lo if_id 42
ip -n foo link set xfrmi0 netns bar
ip netns del foo
ip netns del bar

Which results to:
[  186.686395] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6bd3: 0000 [#1] SMP PTI
[  186.687665] CPU: 7 PID: 232 Comm: kworker/u16:2 Not tainted 5.6.0+ #1
[  186.688430] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
[  186.689420] Workqueue: netns cleanup_net
[  186.689903] RIP: 0010:xfrmi_dev_uninit+0x1b/0x4b [xfrm_interface]
[  186.690657] Code: 44 f6 ff ff 31 c0 5b 5d 41 5c 41 5d 41 5e c3 48 8d 8f c0 08 00 00 8b 05 ce 14 00 00 48 8b 97 d0 08 00 00 48 8b 92 c0 0e 00 00 <48> 8b 14 c2 48 8b 02 48 85 c0 74 19 48 39 c1 75 0c 48 8b 87 c0 08
[  186.692838] RSP: 0018:ffffc900003b7d68 EFLAGS: 00010286
[  186.693435] RAX: 000000000000000d RBX: ffff8881b0f31000 RCX: ffff8881b0f318c0
[  186.694334] RDX: 6b6b6b6b6b6b6b6b RSI: 0000000000000246 RDI: ffff8881b0f31000
[  186.695190] RBP: ffffc900003b7df0 R08: ffff888236c07740 R09: 0000000000000040
[  186.696024] R10: ffffffff81fce1b8 R11: 0000000000000002 R12: ffffc900003b7d80
[  186.696859] R13: ffff8881edcc6a40 R14: ffff8881a1b6e780 R15: ffffffff81ed47c8
[  186.697738] FS:  0000000000000000(0000) GS:ffff888237dc0000(0000) knlGS:0000000000000000
[  186.698705] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  186.699408] CR2: 00007f2129e93148 CR3: 0000000001e0a000 CR4: 00000000000006e0
[  186.700221] Call Trace:
[  186.700508]  rollback_registered_many+0x32b/0x3fd
[  186.701058]  ? __rtnl_unlock+0x20/0x3d
[  186.701494]  ? arch_local_irq_save+0x11/0x17
[  186.702012]  unregister_netdevice_many+0x12/0x55
[  186.702594]  default_device_exit_batch+0x12b/0x150
[  186.703160]  ? prepare_to_wait_exclusive+0x60/0x60
[  186.703719]  cleanup_net+0x17d/0x234
[  186.704138]  process_one_work+0x196/0x2e8
[  186.704652]  worker_thread+0x1a4/0x249
[  186.705087]  ? cancel_delayed_work+0x92/0x92
[  186.705620]  kthread+0x105/0x10f
[  186.706000]  ? __kthread_bind_mask+0x57/0x57
[  186.706501]  ret_from_fork+0x35/0x40
[  186.706978] Modules linked in: xfrm_interface nfsv3 nfs_acl auth_rpcgss nfsv4 nfs lockd grace fscache sunrpc button parport_pc parport serio_raw evdev pcspkr loop ext4 crc16 mbcache jbd2 crc32c_generic 8139too ide_cd_mod cdrom ide_gd_mod ata_generic ata_piix libata scsi_mod piix psmouse i2c_piix4 ide_core 8139cp i2c_core mii floppy
[  186.710423] ---[ end trace 463bba18105537e5 ]---

The problem is that x-netns xfrm interface are not removed when the link
netns is removed. This causes later this oops when thoses interfaces are
removed.

Let's add a handler to remove all interfaces related to a netns when this
netns is removed.

Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Reported-by: Christophe Gouault <christophe.gouault@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/xfrm/xfrm_interface.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -780,7 +780,28 @@ static void __net_exit xfrmi_exit_net(st
 	rtnl_unlock();
 }
 
+static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list)
+{
+	struct net *net;
+	LIST_HEAD(list);
+
+	rtnl_lock();
+	list_for_each_entry(net, net_exit_list, exit_list) {
+		struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id);
+		struct xfrm_if __rcu **xip;
+		struct xfrm_if *xi;
+
+		for (xip = &xfrmn->xfrmi[0];
+		     (xi = rtnl_dereference(*xip)) != NULL;
+		     xip = &xi->next)
+			unregister_netdevice_queue(xi->dev, &list);
+	}
+	unregister_netdevice_many(&list);
+	rtnl_unlock();
+}
+
 static struct pernet_operations xfrmi_net_ops = {
+	.exit_batch = xfrmi_exit_batch_net,
 	.init = xfrmi_init_net,
 	.exit = xfrmi_exit_net,
 	.id   = &xfrmi_net_id,



  parent reply	other threads:[~2020-06-01 18:50 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 17:53 [PATCH 4.19 00/95] 4.19.126-rc1 review Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 01/95] ax25: fix setsockopt(SO_BINDTODEVICE) Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 02/95] dpaa_eth: fix usage as DSA master, try 3 Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 03/95] net: dsa: mt7530: fix roaming from DSA user ports Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 04/95] __netif_receive_skb_core: pass skb by reference Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 05/95] net: inet_csk: Fix so_reuseport bind-address cache in tb->fast* Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 06/95] net: ipip: fix wrong address family in init error path Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 07/95] net/mlx5: Add command entry handling completion Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 08/95] net: qrtr: Fix passing invalid reference to qrtr_local_enqueue() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 09/95] net: revert "net: get rid of an signed integer overflow in ip_idents_reserve()" Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 10/95] net sched: fix reporting the first-time use timestamp Greg Kroah-Hartman
2020-06-01 20:59   ` Pavel Machek
2020-06-01 17:53 ` [PATCH 4.19 11/95] r8152: support additional Microsoft Surface Ethernet Adapter variant Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 12/95] sctp: Dont add the shutdown timer if its already been added Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 13/95] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 14/95] net/mlx5e: Update netdev txq on completions during closure Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 15/95] net/mlx5: Annotate mutex destroy for root ns Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 16/95] net: sun: fix missing release regions in cas_init_one() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 17/95] net/mlx4_core: fix a memory leak bug Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 18/95] mlxsw: spectrum: Fix use-after-free of split/unsplit/type_set in case reload fails Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 19/95] ARM: dts: rockchip: fix phy nodename for rk3228-evb Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 20/95] arm64: dts: rockchip: fix status for &gmac2phy in rk3328-evb.dts Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 21/95] arm64: dts: rockchip: swap interrupts interrupt-names rk3399 gpu node Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 22/95] ARM: dts: rockchip: swap clock-names of gpu nodes Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 23/95] ARM: dts: rockchip: fix pinctrl sub nodename for spi in rk322x.dtsi Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 24/95] gpio: tegra: mask GPIO IRQs during IRQ shutdown Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 25/95] ALSA: usb-audio: add mapping for ASRock TRX40 Creator Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 26/95] net: microchip: encx24j600: add missed kthread_stop Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 27/95] gfs2: move privileged user check to gfs2_quota_lock_check Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 28/95] gfs2: dont call quota_unhold if quotas are not locked Greg Kroah-Hartman
2020-06-01 20:58   ` Pavel Machek
2020-06-01 17:53 ` [PATCH 4.19 29/95] cachefiles: Fix race between read_waiter and read_copier involving op->to_do Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 30/95] usb: dwc3: pci: Enable extcon driver for Intel Merrifield Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 31/95] usb: gadget: legacy: fix redundant initialization warnings Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 32/95] net: freescale: select CONFIG_FIXED_PHY where needed Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 33/95] IB/i40iw: Remove bogus call to netdev_master_upper_dev_get() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 34/95] riscv: stacktrace: Fix undefined reference to `walk_stackframe Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 35/95] cifs: Fix null pointer check in cifs_read Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 36/95] samples: bpf: Fix build error Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 37/95] Input: usbtouchscreen - add support for BonXeon TP Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 38/95] Input: i8042 - add ThinkPad S230u to i8042 nomux list Greg Kroah-Hartman
2020-06-01 21:38   ` Pavel Machek
2020-06-02  2:10     ` Sasha Levin
2020-06-01 17:53 ` [PATCH 4.19 39/95] Input: evdev - call input_flush_device() on release(), not flush() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 40/95] Input: xpad - add custom init packet for Xbox One S controllers Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 41/95] Input: dlink-dir685-touchkeys - fix a typo in driver name Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 42/95] Input: i8042 - add ThinkPad S230u to i8042 reset list Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 43/95] Input: synaptics-rmi4 - really fix attn_data use-after-free Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 44/95] Input: synaptics-rmi4 - fix error return code in rmi_driver_probe() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 45/95] ARM: 8970/1: decompressor: increase tag size Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 46/95] ARM: 8843/1: use unified assembler in headers Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 47/95] ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 48/95] ARM: uaccess: integrate uaccess_save and uaccess_restore Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 49/95] ARM: uaccess: fix DACR mismatch with nested exceptions Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 50/95] gpio: exar: Fix bad handling for ida_simple_get error path Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 51/95] IB/qib: Call kobject_put() when kobject_init_and_add() fails Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 52/95] ARM: dts/imx6q-bx50v3: Set display interface clock parents Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 53/95] ARM: dts: bcm2835-rpi-zero-w: Fix led polarity Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 54/95] ARM: dts: bcm: HR2: Fix PPI interrupt types Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 55/95] mmc: block: Fix use-after-free issue for rpmb Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 56/95] RDMA/pvrdma: Fix missing pci disable in pvrdma_pci_probe() Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 57/95] ALSA: hwdep: fix a left shifting 1 by 31 UB bug Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 58/95] ALSA: hda/realtek - Add a model for Thinkpad T570 without DAC workaround Greg Kroah-Hartman
2020-06-01 17:53 ` [PATCH 4.19 59/95] ALSA: usb-audio: mixer: volume quirk for ESS Technology Asus USB DAC Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 60/95] exec: Always set cap_ambient in cap_bprm_set_creds Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 61/95] ALSA: usb-audio: Quirks for Gigabyte TRX40 Aorus Master onboard audio Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 62/95] ALSA: hda/realtek - Add new codec supported for ALC287 Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 63/95] libceph: ignore pool overlay and cache logic on redirects Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 64/95] IB/ipoib: Fix double free of skb in case of multicast traffic in CM mode Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 65/95] mm: remove VM_BUG_ON(PageSlab()) from page_mapcount() Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 66/95] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info() Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 67/95] include/asm-generic/topology.h: guard cpumask_of_node() macro argument Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 68/95] iommu: Fix reference count leak in iommu_group_alloc Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 69/95] parisc: Fix kernel panic in mem_init() Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 70/95] mmc: core: Fix recursive locking issue in CQE recovery path Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 71/95] RDMA/core: Fix double destruction of uobject Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 72/95] mac80211: mesh: fix discovery timer re-arming issue / crash Greg Kroah-Hartman
2020-06-01 21:09   ` Pavel Machek
2020-06-01 17:54 ` [PATCH 4.19 73/95] x86/dma: Fix max PFN arithmetic overflow on 32 bit systems Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 74/95] copy_xstate_to_kernel(): dont leave parts of destination uninitialized Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 75/95] xfrm: allow to accept packets with ipv6 NEXTHDR_HOP in xfrm_input Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 76/95] xfrm: call xfrm_output_gso when inner_protocol is set in xfrm_output Greg Kroah-Hartman
2020-06-01 17:54 ` Greg Kroah-Hartman [this message]
2020-06-01 17:54 ` [PATCH 4.19 78/95] xfrm: fix a warning in xfrm_policy_insert_list Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 79/95] xfrm: fix a NULL-ptr deref in xfrm_local_error Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 80/95] xfrm: fix error in comment Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 81/95] vti4: eliminated some duplicate code Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 82/95] ip_vti: receive ipip packet by calling ip_tunnel_rcv Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 83/95] netfilter: nft_reject_bridge: enable reject with bridge vlan Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 84/95] netfilter: ipset: Fix subcounter update skip Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 85/95] netfilter: nfnetlink_cthelper: unbreak userspace helper support Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 86/95] netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 87/95] esp6: get the right proto for transport mode in esp6_gso_encap Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 88/95] bnxt_en: Fix accumulation of bp->net_stats_prev Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 89/95] xsk: Add overflow check for u64 division, stored into u32 Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 90/95] qlcnic: fix missing release in qlcnic_83xx_interrupt_test Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 91/95] crypto: chelsio/chtls: properly set tp->lsndtime Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 92/95] bonding: Fix reference count leak in bond_sysfs_slave_add Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 93/95] Revert "Input: i8042 - add ThinkPad S230u to i8042 nomux list" Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 94/95] netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build Greg Kroah-Hartman
2020-06-01 17:54 ` [PATCH 4.19 95/95] mm/vmalloc.c: dont dereference possible NULL pointer in __vunmap() Greg Kroah-Hartman
2020-06-01 21:17 ` [PATCH 4.19 00/95] 4.19.126-rc1 review Chris Paterson
2020-06-02 19:22   ` Greg Kroah-Hartman
2020-06-02  7:45 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200601174032.556673050@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=christophe.gouault@6wind.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).