linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nikolay Aleksandrov <nikolay@nvidia.com>,
	"David S . Miller" <davem@davemloft.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 4.14 56/88] net: bridge: fix vlan tunnel dst refcnt when egressing
Date: Mon, 28 Jun 2021 10:35:56 -0400	[thread overview]
Message-ID: <20210628143628.33342-57-sashal@kernel.org> (raw)
In-Reply-To: <20210628143628.33342-1-sashal@kernel.org>

From: Nikolay Aleksandrov <nikolay@nvidia.com>

commit cfc579f9d89af4ada58c69b03bcaa4887840f3b3 upstream.

The egress tunnel code uses dst_clone() and directly sets the result
which is wrong because the entry might have 0 refcnt or be already deleted,
causing number of problems. It also triggers the WARN_ON() in dst_hold()[1]
when a refcnt couldn't be taken. Fix it by using dst_hold_safe() and
checking if a reference was actually taken before setting the dst.

[1] dmesg WARN_ON log and following refcnt errors
 WARNING: CPU: 5 PID: 38 at include/net/dst.h:230 br_handle_egress_vlan_tunnel+0x10b/0x134 [bridge]
 Modules linked in: 8021q garp mrp bridge stp llc bonding ipv6 virtio_net
 CPU: 5 PID: 38 Comm: ksoftirqd/5 Kdump: loaded Tainted: G        W         5.13.0-rc3+ #360
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014
 RIP: 0010:br_handle_egress_vlan_tunnel+0x10b/0x134 [bridge]
 Code: e8 85 bc 01 e1 45 84 f6 74 90 45 31 f6 85 db 48 c7 c7 a0 02 19 a0 41 0f 94 c6 31 c9 31 d2 44 89 f6 e8 64 bc 01 e1 85 db 75 02 <0f> 0b 31 c9 31 d2 44 89 f6 48 c7 c7 70 02 19 a0 e8 4b bc 01 e1 49
 RSP: 0018:ffff8881003d39e8 EFLAGS: 00010246
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffffa01902a0
 RBP: ffff8881040c6700 R08: 0000000000000000 R09: 0000000000000001
 R10: 2ce93d0054fe0d00 R11: 54fe0d00000e0000 R12: ffff888109515000
 R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000401
 FS:  0000000000000000(0000) GS:ffff88822bf40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 00007f42ba70f030 CR3: 0000000109926000 CR4: 00000000000006e0
 Call Trace:
  br_handle_vlan+0xbc/0xca [bridge]
  __br_forward+0x23/0x164 [bridge]
  deliver_clone+0x41/0x48 [bridge]
  br_handle_frame_finish+0x36f/0x3aa [bridge]
  ? skb_dst+0x2e/0x38 [bridge]
  ? br_handle_ingress_vlan_tunnel+0x3e/0x1c8 [bridge]
  ? br_handle_frame_finish+0x3aa/0x3aa [bridge]
  br_handle_frame+0x2c3/0x377 [bridge]
  ? __skb_pull+0x33/0x51
  ? vlan_do_receive+0x4f/0x36a
  ? br_handle_frame_finish+0x3aa/0x3aa [bridge]
  __netif_receive_skb_core+0x539/0x7c6
  ? __list_del_entry_valid+0x16e/0x1c2
  __netif_receive_skb_list_core+0x6d/0xd6
  netif_receive_skb_list_internal+0x1d9/0x1fa
  gro_normal_list+0x22/0x3e
  dev_gro_receive+0x55b/0x600
  ? detach_buf_split+0x58/0x140
  napi_gro_receive+0x94/0x12e
  virtnet_poll+0x15d/0x315 [virtio_net]
  __napi_poll+0x2c/0x1c9
  net_rx_action+0xe6/0x1fb
  __do_softirq+0x115/0x2d8
  run_ksoftirqd+0x18/0x20
  smpboot_thread_fn+0x183/0x19c
  ? smpboot_unregister_percpu_thread+0x66/0x66
  kthread+0x10a/0x10f
  ? kthread_mod_delayed_work+0xb6/0xb6
  ret_from_fork+0x22/0x30
 ---[ end trace 49f61b07f775fd2b ]---
 dst_release: dst:00000000c02d677a refcnt:-1
 dst_release underflow

Cc: stable@vger.kernel.org
Fixes: 11538d039ac6 ("bridge: vlan dst_metadata hooks in ingress and egress paths")
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/bridge/br_vlan_tunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_vlan_tunnel.c b/net/bridge/br_vlan_tunnel.c
index 4d5100677c68..adb6845ceba4 100644
--- a/net/bridge/br_vlan_tunnel.c
+++ b/net/bridge/br_vlan_tunnel.c
@@ -208,8 +208,8 @@ int br_handle_egress_vlan_tunnel(struct sk_buff *skb,
 		return err;
 
 	tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst);
-	if (tunnel_dst)
-		skb_dst_set(skb, dst_clone(&tunnel_dst->dst));
+	if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst))
+		skb_dst_set(skb, &tunnel_dst->dst);
 
 	return 0;
 }
-- 
2.30.2


  parent reply	other threads:[~2021-06-28 15:15 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 14:35 [PATCH 4.14 00/88] 4.14.238-rc1 review Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 01/88] net: ieee802154: fix null deref in parse dev addr Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 02/88] HID: hid-sensor-hub: Return error for hid_set_field() failure Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 03/88] HID: Add BUS_VIRTUAL to hid_connect logging Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 04/88] HID: usbhid: fix info leak in hid_submit_ctrl Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 05/88] ARM: OMAP2+: Fix build warning when mmc_omap is not built Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 06/88] HID: gt683r: add missing MODULE_DEVICE_TABLE Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 07/88] gfs2: Fix use-after-free in gfs2_glock_shrink_scan Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 08/88] scsi: target: core: Fix warning on realtime kernels Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 09/88] ethernet: myri10ge: Fix missing error code in myri10ge_probe() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 10/88] nvme-loop: reset queue count to 1 in nvme_loop_destroy_io_queues() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 11/88] nvme-loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 12/88] nvme-loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 13/88] net: ipconfig: Don't override command-line hostnames or domains Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 14/88] rtnetlink: Fix missing error code in rtnl_bridge_notify() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 15/88] net/x25: Return the correct errno code Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 16/88] net: " Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 17/88] fib: " Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 18/88] dmaengine: ALTERA_MSGDMA depends on HAS_IOMEM Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 19/88] dmaengine: QCOM_HIDMA_MGMT " Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 20/88] dmaengine: stedma40: add missing iounmap() on error in d40_probe() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 21/88] mm/memory-failure: make sure wait for page writeback in memory_failure Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 22/88] batman-adv: Avoid WARN_ON timing related checks Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 23/88] net: ipv4: fix memory leak in netlbl_cipsov4_add_std Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 24/88] net: rds: fix memory leak in rds_recvmsg Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 25/88] udp: fix race between close() and udp_abort() Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 26/88] rtnetlink: Fix regression in bridge VLAN configuration Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 27/88] netfilter: synproxy: Fix out of bounds when parsing TCP options Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 28/88] alx: Fix an error handling path in 'alx_probe()' Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 29/88] net: stmmac: dwmac1000: Fix extended MAC address registers definition Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 30/88] qlcnic: Fix an error handling path in 'qlcnic_probe()' Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 31/88] netxen_nic: Fix an error handling path in 'netxen_nic_probe()' Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 32/88] net: cdc_ncm: switch to eth%d interface naming Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 33/88] net: usb: fix possible use-after-free in smsc75xx_bind Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 34/88] net: ipv4: fix memory leak in ip_mc_add1_src Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 35/88] net/af_unix: fix a data-race in unix_dgram_sendmsg / unix_release_sock Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 36/88] be2net: Fix an error handling path in 'be_probe()' Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 37/88] net: hamradio: fix memory leak in mkiss_close Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 38/88] net: cdc_eem: fix tx fixup skb leak Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 39/88] icmp: don't send out ICMP messages with a source address of 0.0.0.0 Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 40/88] net: ethernet: fix potential use-after-free in ec_bhf_remove Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 41/88] radeon: use memcpy_to/fromio for UVD fw upload Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 42/88] hwmon: (scpi-hwmon) shows the negative temperature properly Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 43/88] can: bcm: fix infoleak in struct bcm_msg_head Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 44/88] can: mcba_usb: fix memory leak in mcba_usb Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 45/88] usb: core: hub: Disable autosuspend for Cypress CY7C65632 Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 46/88] tracing: Do not stop recording cmdlines when tracing is off Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 47/88] tracing: Do not stop recording comms if the trace file is being read Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 48/88] tracing: Do no increment trace_clock_global() by one Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 49/88] PCI: Mark TI C667X to avoid bus reset Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 50/88] PCI: Mark some NVIDIA GPUs " Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 51/88] PCI: Add ACS quirk for Broadcom BCM57414 NIC Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 52/88] PCI: Work around Huawei Intelligent NIC VF FLR erratum Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 53/88] ARCv2: save ABI registers across signal handling Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 54/88] dmaengine: pl330: fix wrong usage of spinlock flags in dma_cyclc Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 55/88] net: bridge: fix vlan tunnel dst null pointer dereference Sasha Levin
2021-06-28 14:35 ` Sasha Levin [this message]
2021-06-28 14:35 ` [PATCH 4.14 57/88] mm/slub.c: include swab.h Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 58/88] net: fec_ptp: add clock rate zero check Sasha Levin
2021-06-28 14:35 ` [PATCH 4.14 59/88] can: bcm/raw/isotp: use per module netdevice notifier Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 60/88] inet: use bigger hash table for IP ID generation Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 61/88] usb: dwc3: core: fix kernel panic when do reboot Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 62/88] kernfs: deal with kernfs_fill_super() failures Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 63/88] unfuck sysfs_mount() Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 64/88] x86/fpu: Reset state for all signal restore failures Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 65/88] drm/nouveau: wait for moving fence after pinning v2 Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 66/88] drm/radeon: wait for moving fence after pinning Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 67/88] ARM: 9081/1: fix gcc-10 thumb2-kernel regression Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 68/88] Makefile: Move -Wno-unused-but-set-variable out of GCC only block Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 69/88] MIPS: generic: Update node names to avoid unit addresses Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 70/88] arm64: perf: Disable PMU while processing counter overflows Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 71/88] Revert "PCI: PM: Do not read power state in pci_enable_device_flags()" Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 72/88] mac80211: remove warning in ieee80211_get_sband() Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 73/88] cfg80211: call cfg80211_leave_ocb when switching away from OCB Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 74/88] mac80211: drop multicast fragments Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 75/88] ping: Check return value of function 'ping_queue_rcv_skb' Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 76/88] inet: annotate date races around sk->sk_txhash Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 77/88] net: caif: fix memory leak in ldisc_open Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 78/88] net/packet: annotate accesses to po->bind Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 79/88] net/packet: annotate accesses to po->ifindex Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 80/88] r8152: Avoid memcpy() over-reading of ETH_SS_STATS Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 81/88] sh_eth: " Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 82/88] r8169: " Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 83/88] net: qed: Fix memcpy() overflow of qed_dcbx_params() Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 84/88] net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 85/88] pinctrl: stm32: fix the reported number of GPIO lines per bank Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 86/88] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 87/88] i2c: robotfuzz-osif: fix control-request directions Sasha Levin
2021-06-28 14:36 ` [PATCH 4.14 88/88] Linux 4.14.238-rc1 Sasha Levin
2021-06-29 11:42 ` [PATCH 4.14 00/88] 4.14.238-rc1 review Naresh Kamboju
2021-06-29 18:19 ` Guenter Roeck
2021-06-30  6:19 ` Samuel Zou

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=20210628143628.33342-57-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=stable@vger.kernel.org \
    /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).