public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Naresh Kamboju <naresh.kamboju@linaro.org>,
	Linux Kernel Functional Testing <lkft@linaro.org>,
	Eric Dumazet <edumazet@google.com>,
	Xin Long <lucien.xin@gmail.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Abdelkareem Abdelsaamad <kareemem@amazon.com>
Subject: [PATCH 6.1 78/98] net: do not delay dst_entries_add() in dst_release()
Date: Tue, 12 Nov 2024 11:21:33 +0100	[thread overview]
Message-ID: <20241112101847.225273849@linuxfoundation.org> (raw)
In-Reply-To: <20241112101844.263449965@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@google.com>

commit ac888d58869bb99753e7652be19a151df9ecb35d upstream.

dst_entries_add() uses per-cpu data that might be freed at netns
dismantle from ip6_route_net_exit() calling dst_entries_destroy()

Before ip6_route_net_exit() can be called, we release all
the dsts associated with this netns, via calls to dst_release(),
which waits an rcu grace period before calling dst_destroy()

dst_entries_add() use in dst_destroy() is racy, because
dst_entries_destroy() could have been called already.

Decrementing the number of dsts must happen sooner.

Notes:

1) in CONFIG_XFRM case, dst_destroy() can call
   dst_release_immediate(child), this might also cause UAF
   if the child does not have DST_NOCOUNT set.
   IPSEC maintainers might take a look and see how to address this.

2) There is also discussion about removing this count of dst,
   which might happen in future kernels.

Fixes: f88649721268 ("ipv4: fix dst race in sk_dst_get()")
Closes: https://lore.kernel.org/lkml/CANn89iLCCGsP7SFn9HKpvnKu96Td4KD08xf7aGtiYgZnkjaL=w@mail.gmail.com/T/
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Xin Long <lucien.xin@gmail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20241008143110.1064899-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ resolved conflict due to bc9d3a9f2afc ("net: dst: Switch to rcuref_t
  reference counting") is not in the tree ]
Signed-off-by: Abdelkareem Abdelsaamad <kareemem@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/core/dst.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -108,9 +108,6 @@ struct dst_entry *dst_destroy(struct dst
 		child = xdst->child;
 	}
 #endif
-	if (!(dst->flags & DST_NOCOUNT))
-		dst_entries_add(dst->ops, -1);
-
 	if (dst->ops->destroy)
 		dst->ops->destroy(dst);
 	netdev_put(dst->dev, &dst->dev_tracker);
@@ -160,6 +157,12 @@ void dst_dev_put(struct dst_entry *dst)
 }
 EXPORT_SYMBOL(dst_dev_put);
 
+static void dst_count_dec(struct dst_entry *dst)
+{
+	if (!(dst->flags & DST_NOCOUNT))
+		dst_entries_add(dst->ops, -1);
+}
+
 void dst_release(struct dst_entry *dst)
 {
 	if (dst) {
@@ -169,8 +172,10 @@ void dst_release(struct dst_entry *dst)
 		if (WARN_ONCE(newrefcnt < 0, "dst_release underflow"))
 			net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
 					     __func__, dst, newrefcnt);
-		if (!newrefcnt)
+		if (!newrefcnt){
+			dst_count_dec(dst);
 			call_rcu(&dst->rcu_head, dst_destroy_rcu);
+		}
 	}
 }
 EXPORT_SYMBOL(dst_release);
@@ -184,8 +189,10 @@ void dst_release_immediate(struct dst_en
 		if (WARN_ONCE(newrefcnt < 0, "dst_release_immediate underflow"))
 			net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
 					     __func__, dst, newrefcnt);
-		if (!newrefcnt)
+		if (!newrefcnt){
+			dst_count_dec(dst);
 			dst_destroy(dst);
+		}
 	}
 }
 EXPORT_SYMBOL(dst_release_immediate);



  parent reply	other threads:[~2024-11-12 10:32 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 10:20 [PATCH 6.1 00/98] 6.1.117-rc1 review Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 01/98] arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-eaidk-610 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 02/98] arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-sapphire-excavator Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 03/98] arm64: dts: rockchip: Remove hdmis 2nd interrupt on rk3328 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 04/98] arm64: dts: rockchip: Fix wakeup prop names on PineNote BT node Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 05/98] arm64: dts: rockchip: Fix bluetooth properties on Rock960 boards Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 06/98] arm64: dts: rockchip: Remove #cooling-cells from fan on Theobroma lion Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 07/98] arm64: dts: rockchip: Fix LED triggers on rk3308-roc-cc Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 08/98] arm64: dts: imx8qm: Fix VPU core alias name Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 09/98] arm64: dts: imx8qxp: Add VPU subsystem file Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 10/98] arm64: dts: imx8-ss-vpu: Fix imx8qm VPU IRQs Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 11/98] arm64: dts: imx8mp: correct sdhc ipg clk Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 12/98] ARM: dts: rockchip: fix rk3036 acodec node Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 13/98] ARM: dts: rockchip: drop grf reference from rk3036 hdmi Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 14/98] ARM: dts: rockchip: Fix the spi controller on rk3036 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 15/98] ARM: dts: rockchip: Fix the realtek audio codec on rk3036-kylin Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 16/98] HID: core: zero-initialize the report buffer Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 17/98] platform/x86/amd/pmc: Detect when STB is not available Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 18/98] sunrpc: handle -ENOTCONN in xs_tcp_setup_socket() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 19/98] NFSv3: only use NFS timeout for MOUNT when protocols are compatible Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 20/98] NFSv3: handle out-of-order write replies Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 21/98] nfs: avoid i_lock contention in nfs_clear_invalid_mapping Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 22/98] security/keys: fix slab-out-of-bounds in key_task_permission Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 23/98] net: enetc: set MAC address to the VF net_device Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 24/98] sctp: properly validate chunk size in sctp_sf_ootb() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 25/98] can: c_can: fix {rx,tx}_errors statistics Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 26/98] ice: change q_index variable type to s16 to store -1 value Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 27/98] i40e: fix race condition by adding filters intermediate sync state Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 28/98] net: hns3: fix kernel crash when uninstalling driver Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 29/98] net: phy: ti: add PHY_RST_AFTER_CLK_EN flag Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 30/98] net: stmmac: Fix unbalanced IRQ wake disable warning on single irq case Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 31/98] virtio_net: Add hash_key_length check Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 32/98] net: arc: fix the device for dma_map_single/dma_unmap_single Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 33/98] net: arc: rockchip: fix emac mdio node support Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 34/98] Revert "ALSA: hda/conexant: Mute speakers at suspend / shutdown" Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 35/98] media: stb0899_algo: initialize cfr before using it Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 36/98] media: dvbdev: prevent the risk of out of memory access Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 37/98] media: dvb_frontend: dont play tricks with underflow values Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 38/98] media: adv7604: prevent underflow condition when reporting colorspace Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 39/98] scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 40/98] ALSA: firewire-lib: fix return value on fail in amdtp_tscm_init() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 41/98] tools/lib/thermal: Fix sampling handler context ptr Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 42/98] thermal/of: support thermal zones w/o trips subnode Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 43/98] ASoC: stm32: spdifrx: fix dma channel release in stm32_spdifrx_remove Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 44/98] media: ar0521: dont overflow when checking PLL values Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 45/98] media: s5p-jpeg: prevent buffer overflows Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 46/98] media: cx24116: prevent overflows on SNR calculus Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 47/98] media: pulse8-cec: fix data timestamp at pulse8_setup() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 48/98] media: v4l2-tpg: prevent the risk of a division by zero Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 49/98] media: v4l2-ctrls-api: fix error handling for v4l2_g_ctrl() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 50/98] can: mcp251xfd: mcp251xfd_get_tef_len(): fix length calculation Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 51/98] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 52/98] ksmbd: fix slab-use-after-free in ksmbd_smb2_session_create Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 53/98] ksmbd: Fix the missing xa_store error check Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 54/98] ksmbd: fix slab-use-after-free in smb3_preauth_hash_rsp Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 55/98] pwm: imx-tpm: Use correct MODULO value for EPWM mode Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 56/98] drm/amdgpu: Adjust debugfs eviction and IB access permissions Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 57/98] drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 58/98] drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 59/98] thermal/drivers/qcom/lmh: Remove false lockdep backtrace Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 60/98] dm cache: correct the number of origin blocks to match the target length Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 61/98] dm cache: fix flushing uninitialized delayed_work on cache_ctr error Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 62/98] dm cache: fix out-of-bounds access to the dirty bitset when resizing Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 63/98] dm cache: optimize dirty bit checking with find_next_bit " Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 64/98] dm cache: fix potential out-of-bounds access on the first resume Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 65/98] dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 66/98] ALSA: usb-audio: Add quirk for HP 320 FHD Webcam Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 67/98] ALSA: hda/realtek: Fix headset mic on TUXEDO Gemini 17 Gen3 Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 68/98] posix-cpu-timers: Clear TICK_DEP_BIT_POSIX_TIMER on clone Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 69/98] nfs: Fix KMSAN warning in decode_getfattr_attrs() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 70/98] net: wwan: t7xx: Fix off-by-one error in t7xx_dpmaif_rx_buf_alloc() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 71/98] net: vertexcom: mse102x: Fix possible double free of TX skb Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 72/98] mptcp: use sock_kfree_s instead of kfree Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 73/98] arm64: Kconfig: Make SME depend on BROKEN for now Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 74/98] btrfs: reinitialize delayed ref list after deleting it from the list Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 75/98] riscv/purgatory: align riscv_kernel_entry Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 76/98] bnxt_re: avoid shift undefined behavior in bnxt_qplib_alloc_init_hwq Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 77/98] Revert "wifi: mac80211: fix RCU list iterations" Greg Kroah-Hartman
2024-11-12 10:21 ` Greg Kroah-Hartman [this message]
2024-11-12 10:21 ` [PATCH 6.1 79/98] kselftest/arm64: Initialise current at build time in signal tests Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 80/98] media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 81/98] filemap: Fix bounds checking in filemap_read() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 82/98] fs/proc: fix compile warning about variable vmcore_mmap_ops Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 83/98] signal: restore the override_rlimit logic Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 84/98] usb: musb: sunxi: Fix accessing an released usb phy Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 85/98] usb: dwc3: fix fault at system suspend if device was already runtime suspended Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 86/98] usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 87/98] USB: serial: io_edgeport: fix use after free in debug printk Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 88/98] USB: serial: qcserial: add support for Sierra Wireless EM86xx Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 89/98] USB: serial: option: add Fibocom FG132 0x0112 composition Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 90/98] USB: serial: option: add Quectel RG650V Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 91/98] irqchip/gic-v3: Force propagation of the active state with a read-back Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 92/98] ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 93/98] ucounts: fix counter leak in inc_rlimit_get_ucounts() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 94/98] ASoC: amd: yc: fix internal mic on Xiaomi Book Pro 14 2022 Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 95/98] net: sched: use RCU read-side critical section in taprio_dump() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 96/98] hv_sock: Initializing vsk->trans to NULL to prevent a dangling pointer Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 97/98] vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 98/98] media: amphion: Fix VPU core alias name Greg Kroah-Hartman
2024-11-12 20:56 ` [PATCH 6.1 00/98] 6.1.117-rc1 review Pavel Machek
2024-11-12 23:17 ` Shuah Khan
2024-11-13  0:22 ` Florian Fainelli
2024-11-13  0:38 ` Ron Economos
2024-11-13 11:23 ` Naresh Kamboju
2024-11-13 13:29 ` Mark Brown
2024-11-13 18:35 ` Peter Schneider
2024-11-13 19:58 ` Jon Hunter
2024-11-14 10:50 ` [PATCH 6.1] " Hardik Garg
2024-11-28 18:05 ` [PATCH 6.1 00/98] " Pavel Machek

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=20241112101847.225273849@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=edumazet@google.com \
    --cc=kareemem@amazon.com \
    --cc=lkft@linaro.org \
    --cc=lucien.xin@gmail.com \
    --cc=naresh.kamboju@linaro.org \
    --cc=pabeni@redhat.com \
    --cc=patches@lists.linux.dev \
    --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