patches.lists.linux.dev archive mirror
 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, Kuniyuki Iwashima <kuniyu@google.com>,
	Simon Horman <horms@kernel.org>, Jakub Kicinski <kuba@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 022/109] atm: clip: Fix potential null-ptr-deref in to_atmarpd().
Date: Tue, 15 Jul 2025 15:12:38 +0200	[thread overview]
Message-ID: <20250715130759.769957896@linuxfoundation.org> (raw)
In-Reply-To: <20250715130758.864940641@linuxfoundation.org>

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

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

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit 706cc36477139c1616a9b2b96610a8bb520b7119 ]

atmarpd is protected by RTNL since commit f3a0592b37b8 ("[ATM]: clip
causes unregister hang").

However, it is not enough because to_atmarpd() is called without RTNL,
especially clip_neigh_solicit() / neigh_ops->solicit() is unsleepable.

Also, there is no RTNL dependency around atmarpd.

Let's use a private mutex and RCU to protect access to atmarpd in
to_atmarpd().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250704062416.1613927-2-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/atm/clip.c | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/net/atm/clip.c b/net/atm/clip.c
index 511467bb7fe40..8059b7d1fb931 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -45,7 +45,8 @@
 #include <net/atmclip.h>
 
 static struct net_device *clip_devs;
-static struct atm_vcc *atmarpd;
+static struct atm_vcc __rcu *atmarpd;
+static DEFINE_MUTEX(atmarpd_lock);
 static struct timer_list idle_timer;
 static const struct neigh_ops clip_neigh_ops;
 
@@ -53,24 +54,35 @@ static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
 {
 	struct sock *sk;
 	struct atmarp_ctrl *ctrl;
+	struct atm_vcc *vcc;
 	struct sk_buff *skb;
+	int err = 0;
 
 	pr_debug("(%d)\n", type);
-	if (!atmarpd)
-		return -EUNATCH;
+
+	rcu_read_lock();
+	vcc = rcu_dereference(atmarpd);
+	if (!vcc) {
+		err = -EUNATCH;
+		goto unlock;
+	}
 	skb = alloc_skb(sizeof(struct atmarp_ctrl), GFP_ATOMIC);
-	if (!skb)
-		return -ENOMEM;
+	if (!skb) {
+		err = -ENOMEM;
+		goto unlock;
+	}
 	ctrl = skb_put(skb, sizeof(struct atmarp_ctrl));
 	ctrl->type = type;
 	ctrl->itf_num = itf;
 	ctrl->ip = ip;
-	atm_force_charge(atmarpd, skb->truesize);
+	atm_force_charge(vcc, skb->truesize);
 
-	sk = sk_atm(atmarpd);
+	sk = sk_atm(vcc);
 	skb_queue_tail(&sk->sk_receive_queue, skb);
 	sk->sk_data_ready(sk);
-	return 0;
+unlock:
+	rcu_read_unlock();
+	return err;
 }
 
 static void link_vcc(struct clip_vcc *clip_vcc, struct atmarp_entry *entry)
@@ -607,10 +619,12 @@ static void atmarpd_close(struct atm_vcc *vcc)
 {
 	pr_debug("\n");
 
-	rtnl_lock();
-	atmarpd = NULL;
+	mutex_lock(&atmarpd_lock);
+	RCU_INIT_POINTER(atmarpd, NULL);
+	mutex_unlock(&atmarpd_lock);
+
+	synchronize_rcu();
 	skb_queue_purge(&sk_atm(vcc)->sk_receive_queue);
-	rtnl_unlock();
 
 	pr_debug("(done)\n");
 	module_put(THIS_MODULE);
@@ -631,15 +645,15 @@ static struct atm_dev atmarpd_dev = {
 
 static int atm_init_atmarp(struct atm_vcc *vcc)
 {
-	rtnl_lock();
+	mutex_lock(&atmarpd_lock);
 	if (atmarpd) {
-		rtnl_unlock();
+		mutex_unlock(&atmarpd_lock);
 		return -EADDRINUSE;
 	}
 
 	mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ);
 
-	atmarpd = vcc;
+	rcu_assign_pointer(atmarpd, vcc);
 	set_bit(ATM_VF_META, &vcc->flags);
 	set_bit(ATM_VF_READY, &vcc->flags);
 	    /* allow replies and avoid getting closed if signaling dies */
@@ -648,7 +662,7 @@ static int atm_init_atmarp(struct atm_vcc *vcc)
 	vcc->push = NULL;
 	vcc->pop = NULL; /* crash */
 	vcc->push_oam = NULL; /* crash */
-	rtnl_unlock();
+	mutex_unlock(&atmarpd_lock);
 	return 0;
 }
 
-- 
2.39.5




  parent reply	other threads:[~2025-07-15 13:23 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15 13:12 [PATCH 6.6 000/109] 6.6.99-rc1 review Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 001/109] eventpoll: dont decrement ep refcount while still holding the ep mutex Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 002/109] drm/exynos: exynos7_drm_decon: add vblank check in IRQ handling Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 003/109] ASoC: fsl_asrc: use internal measured ratio for non-ideal ratio mode Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 004/109] perf/core: Fix the WARN_ON_ONCE is out of lock protected region Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 005/109] perf: Revert to requiring CAP_SYS_ADMIN for uprobes Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 006/109] ASoC: cs35l56: probe() should fail if the device ID is not recognized Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 007/109] Bluetooth: hci_sync: Fix not disabling advertising instance Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 008/109] Bluetooth: hci_event: Fix not marking Broadcast Sink BIS as connected Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 009/109] pinctrl: amd: Clear GPIO debounce for suspend Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 010/109] fix proc_sys_compare() handling of in-lookup dentries Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 011/109] netlink: Fix wraparounds of sk->sk_rmem_alloc Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 012/109] vsock: fix `vsock_proto` declaration Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 013/109] tipc: Fix use-after-free in tipc_conn_close() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 014/109] tcp: Correct signedness in skb remaining space calculation Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 015/109] vsock: Fix transport_{g2h,h2g} TOCTOU Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 016/109] vsock: Fix transport_* TOCTOU Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 017/109] vsock: Fix IOCTL_VM_SOCKETS_GET_LOCAL_CID to check also `transport_local` Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 018/109] net: stmmac: Fix interrupt handling for level-triggered mode in DWC_XGMAC2 Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 019/109] net: phy: smsc: Fix Auto-MDIX configuration when disabled by strap Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 020/109] net: phy: smsc: Force predictable MDI-X state on LAN87xx Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 021/109] net: phy: smsc: Fix link failure in forced mode with Auto-MDIX Greg Kroah-Hartman
2025-07-15 13:12 ` Greg Kroah-Hartman [this message]
2025-07-15 13:12 ` [PATCH 6.6 023/109] atm: clip: Fix memory leak of struct clip_vcc Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 024/109] atm: clip: Fix infinite recursive call of clip_push() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 025/109] atm: clip: Fix NULL pointer dereference in vcc_sendmsg() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 026/109] net/sched: Abort __tc_modify_qdisc if parent class does not exist Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 027/109] rxrpc: Fix bug due to prealloc collision Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 028/109] maple_tree: fix MA_STATE_PREALLOC flag in mas_preallocate() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 029/109] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 030/109] Bluetooth: HCI: Set extended advertising data synchronously Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 031/109] rxrpc: Fix oops due to non-existence of prealloc backlog struct Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 032/109] ipmi:msghandler: Fix potential memory corruption in ipmi_create_user() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 033/109] x86/mce/amd: Add default names for MCA banks and blocks Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 034/109] x86/mce/amd: Fix threshold limit reset Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 035/109] x86/mce: Dont remove sysfs if thresholding sysfs init fails Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 036/109] x86/mce: Make sure CMCI banks are cleared during shutdown on Intel Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 037/109] KVM: x86/xen: Allow out of range event channel ports in IRQ routing table Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 038/109] KVM: SVM: Reject SEV{-ES} intra host migration if vCPU creation is in-flight Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 039/109] gre: Fix IPv6 multicast route creation Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 040/109] md/md-bitmap: fix GPF in bitmap_get_stats() Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 041/109] pinctrl: qcom: msm: mark certain pins as invalid for interrupts Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 042/109] wifi: prevent A-MSDU attacks in mesh networks Greg Kroah-Hartman
2025-07-15 13:12 ` [PATCH 6.6 043/109] drm/gem: Acquire references on GEM handles for framebuffers Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 044/109] drm/sched: Increment job count before swapping tail spsc queue Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 045/109] drm/ttm: fix error handling in ttm_buffer_object_transfer Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 046/109] drm/gem: Fix race in drm_gem_handle_create_tail() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 047/109] usb: gadget: u_serial: Fix race condition in TTY wakeup Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 048/109] Revert "usb: gadget: u_serial: Add null pointer check in gs_start_io" Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 049/109] drm/framebuffer: Acquire internal references on GEM handles Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 050/109] Revert "ACPI: battery: negate current when discharging" Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 051/109] kallsyms: fix build without execinfo Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 052/109] maple_tree: fix mt_destroy_walk() on root leaf node Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 053/109] mm: fix the inaccurate memory statistics issue for users Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 054/109] scripts/gdb: fix interrupts display after MCP on x86 Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 055/109] scripts/gdb: de-reference per-CPU MCE interrupts Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 056/109] scripts/gdb: fix interrupts.py after maple tree conversion Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 057/109] mm/vmalloc: leave lazy MMU mode on PTE mapping error Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 058/109] pwm: mediatek: Ensure to disable clocks in error path Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 059/109] x86/rdrand: Disable RDSEED on AMD Cyan Skillfish Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 060/109] x86/mm: Disable hugetlb page table sharing on 32-bit Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 061/109] smb: server: make use of rdma_destroy_qp() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 062/109] ksmbd: fix a mount write count leak in ksmbd_vfs_kern_path_locked() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 063/109] erofs: fix to add missing tracepoint in erofs_read_folio() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 064/109] netlink: Fix rmem check in netlink_broadcast_deliver() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 065/109] netlink: make sure we allow at least one dump skb Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 066/109] btrfs: remove noinline from btrfs_update_inode() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 067/109] btrfs: remove redundant root argument from btrfs_update_inode_fallback() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 068/109] btrfs: remove redundant root argument from fixup_inode_link_count() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 069/109] btrfs: return a btrfs_inode from btrfs_iget_logging() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 070/109] btrfs: fix inode lookup error handling during log replay Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 071/109] usb:cdnsp: remove TRB_FLUSH_ENDPOINT command Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 072/109] usb: cdnsp: Replace snprintf() with the safer scnprintf() variant Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 073/109] usb: cdnsp: Fix issue with CV Bad Descriptor test Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 074/109] usb: dwc3: Abort suspend on soft disconnect failure Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 075/109] smb: client: avoid unnecessary reconnects when refreshing referrals Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 076/109] smb: client: fix DFS interlink failover Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 077/109] cifs: all initializations for tcon should happen in tcon_info_alloc Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 078/109] wifi: zd1211rw: Fix potential NULL pointer dereference in zd_mac_tx_to_dev() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 079/109] drm/tegra: nvdec: Fix dma_alloc_coherent error check Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 080/109] md/raid1: Fix stack memory use after return in raid1_reshape Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 081/109] raid10: cleanup memleak at raid10_make_request Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 082/109] nbd: fix uaf in nbd_genl_connect() error path Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 083/109] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 084/109] net: appletalk: Fix device refcount leak in atrtr_create() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 085/109] ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 086/109] net: phy: microchip: limit 100M workaround to link-down events on LAN88xx Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 087/109] can: m_can: m_can_handle_lost_msg(): downgrade msg lost in rx message to debug level Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 088/109] net: ll_temac: Fix missing tx_pending check in ethtools_set_ringparam() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 089/109] bnxt_en: Fix DCB ETS validation Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 090/109] bnxt_en: Set DMA unmap len correctly for XDP_REDIRECT Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 091/109] ublk: sanity check add_dev input for underflow Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 092/109] atm: idt77252: Add missing `dma_map_error()` Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 093/109] um: vector: Reduce stack usage in vector_eth_configure() Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 094/109] io_uring: make fallocate be hashed work Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 095/109] ASoC: amd: yc: add quirk for Acer Nitro ANV15-41 internal mic Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 096/109] ALSA: hda/realtek - Enable mute LED on HP Pavilion Laptop 15-eg100 Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 097/109] net: usb: qmi_wwan: add SIMCom 8230C composition Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 098/109] HID: lenovo: Add support for ThinkPad X1 Tablet Thin Keyboard Gen2 Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 099/109] net: mana: Record doorbell physical address in PF mode Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 100/109] btrfs: fix assertion when building free space tree Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 101/109] vt: add missing notification when switching back to text mode Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 102/109] bpf: Adjust free target to avoid global starvation of LRU map Greg Kroah-Hartman
2025-07-15 13:13 ` [PATCH 6.6 103/109] HID: Add IGNORE quirk for SMARTLINKTECHNOLOGY Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 104/109] HID: quirks: Add quirk for 2 Chicony Electronics HP 5MP Cameras Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 105/109] Input: atkbd - do not skip atkbd_deactivate() when skipping ATKBD_CMD_GETID Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 106/109] selftests/bpf: adapt one more case in test_lru_map to the new target_free Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 107/109] smb: client: fix potential race in cifs_put_tcon() Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 108/109] kasan: remove kasan_find_vm_area() to prevent possible deadlock Greg Kroah-Hartman
2025-07-15 13:14 ` [PATCH 6.6 109/109] ksmbd: fix potential use-after-free in oplock/lease break ack Greg Kroah-Hartman
2025-07-15 17:00 ` [PATCH 6.6 000/109] 6.6.99-rc1 review Miguel Ojeda
2025-07-16 14:53 ` Shuah Khan

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=20250715130759.769957896@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --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).