mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] fastrpc: fix probe-time races between rpmsg and userspace
@ 2026-11-16 13:27 Vinayak Katoch
  2026-11-16 13:27 ` [PATCH v3 1/2] misc: fastrpc: fix NULL rpdev dereference when session alloc fails Vinayak Katoch
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vinayak Katoch @ 2026-11-16 13:27 UTC (permalink / raw)
  To: Srinivas Kandagatla, Ekansh Gupta, Arnd Bergmann,
	Greg Kroah-Hartman, Thierry Escande
  Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
	linux-kernel, Vinayak Katoch, stable, Tyler Baker

This series fixes two races in fastrpc_rpmsg_probe() that can be
triggered when userspace opens a fastrpc device node concurrently with
the rpmsg probe sequence.

fastrpc_device_register() calls misc_register() before the channel
context is fully initialised. A concurrent open() in that window hits
kref_get() on a zero refcount, and because of_platform_populate() has
not yet run, sesscount is 0. The error path then calls kref_put() on the
saturated refcount, which kfree()s the channel context. A subsequent
IRQ-path fastrpc_rpmsg_callback() dereferences the freed spinlock,
causing a kernel panic.

A NULL dereference in the fastrpc_device_open() error path when
cctx->rpdev is concurrently cleared by fastrpc_rpmsg_remove() is also
addressed.

Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
Changes in v3:
- Drop the dependency on the dup-sessions series; use
  of_platform_populate()/of_platform_depopulate() directly in the init
  ordering patch
- Fix Fixes: tag of the init ordering patch to 965602eabb57
- Rebase onto next-20261113
- Collect Tested-by on the NULL rpdev patch (unchanged from v2)
- Link to v2: https://lore.kernel.org/r/20261022-fastrpc-probe-fixes-v2-0-a6b3f6f62571@oss.qualcomm.com

Changes in v2:
- Add Cc: stable to both fixes
- Free cctx via fastrpc_channel_ctx_put() in the probe error path
- Clear rpdev and wake pending users there, as remove() does
- Move fastrpc_notify_users() above probe
- Link to v1: https://lore.kernel.org/r/20261001-fastrpc-probe-fixes-v1-0-1376d93b8b3e@oss.qualcomm.com

---
Vinayak Katoch (2):
      misc: fastrpc: fix NULL rpdev dereference when session alloc fails
      misc: fastrpc: fix init ordering race in rpmsg probe

 drivers/misc/fastrpc.c | 94 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 56 insertions(+), 38 deletions(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20260923-fastrpc-probe-fixes-30c1980b50e6

Best regards,
-- 
Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-16 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 13:27 [PATCH v3 0/2] fastrpc: fix probe-time races between rpmsg and userspace Vinayak Katoch
2026-11-16 13:27 ` [PATCH v3 1/2] misc: fastrpc: fix NULL rpdev dereference when session alloc fails Vinayak Katoch
2026-11-16 13:27 ` [PATCH v3 2/2] misc: fastrpc: fix init ordering race in rpmsg probe Vinayak Katoch
2026-11-16 13:57 ` [PATCH v3 0/2] fastrpc: fix probe-time races between rpmsg and userspace Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®