From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>,
stable@vger.kernel.org,
Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
Tyler Baker <tyler.baker@oss.qualcomm.com>,
Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 1/6] misc: fastrpc: fix NULL rpdev dereference when session alloc fails
Date: Fri, 27 Nov 2026 10:43:49 +0000 [thread overview]
Message-ID: <20261127104354.8452-2-srini@kernel.org> (raw)
In-Reply-To: <20261127104354.8452-1-srini@kernel.org>
From: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
When a fastrpc client process dies abnormally without closing its file
descriptor, fastrpc_device_release() is never called and the compute-cb
session slot is never freed. The abnormal client death on the DSP side
triggers a glink channel teardown which propagates up through the rpmsg
bus and calls fastrpc_rpmsg_remove().
fastrpc_rpmsg_remove() nulls cctx->rpdev before calling
misc_deregister(). If a concurrent open() enters fastrpc_device_open()
in this window and fastrpc_session_alloc() returns NULL (sessions
exhausted by the leaked slot), the error path dereferences
cctx->rpdev->dev causing a NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
pc : fastrpc_device_open+0x1b8/0x258 [fastrpc]
Call trace:
fastrpc_device_open+0x1b8/0x258 [fastrpc] (P)
misc_open+0xd8/0x1a0
Fix by moving misc_deregister() before rpdev = NULL. misc_open() and
misc_deregister() both take misc_mtx, so misc_deregister() will either
block until fastrpc_device_open() completes or prevent new opens from
entering it entirely.
Fixes: 7c11df42d0c7 ("misc: fastrpc: Fix device_open when no session is available")
Cc: stable@vger.kernel.org
Reviewed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Tested-by: Tyler Baker <tyler.baker@oss.qualcomm.com> # Eliza EVK, EL2
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
Fixes: 46248400d81e ("misc: fastrpc: reject new invocations during device removal")
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
drivers/misc/fastrpc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index af18ff1992ee..4f1c6ff8054c 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2675,6 +2675,12 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
struct fastrpc_user *user;
unsigned long flags;
+ if (cctx->fdevice)
+ misc_deregister(&cctx->fdevice->miscdev);
+
+ if (cctx->secure_fdevice)
+ misc_deregister(&cctx->secure_fdevice->miscdev);
+
/* No invocations past this point */
spin_lock_irqsave(&cctx->lock, flags);
cctx->rpdev = NULL;
@@ -2682,12 +2688,6 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
fastrpc_notify_users(user);
spin_unlock_irqrestore(&cctx->lock, flags);
- if (cctx->fdevice)
- misc_deregister(&cctx->fdevice->miscdev);
-
- if (cctx->secure_fdevice)
- misc_deregister(&cctx->secure_fdevice->miscdev);
-
list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node)
list_del(&buf->node);
--
2.53.0
next prev parent reply other threads:[~2026-11-27 10:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:43 [PATCH 0/6] misc: fastrpc: fixes for v7.4 srini
2026-11-27 10:43 ` srini [this message]
2026-11-27 10:43 ` [PATCH 2/6] misc: fastrpc: fix init ordering race in rpmsg probe srini
2026-11-27 10:43 ` [PATCH 3/6] misc: fastrpc: remove dead context drain in fastrpc_user_free() srini
2026-11-27 10:43 ` [PATCH 4/6] misc: fastrpc: drop the DSP-response reference on channel removal srini
2026-11-27 10:43 ` [PATCH 5/6] misc: fastrpc: fix context leak and hang on signal-interrupted invoke srini
2026-11-27 10:43 ` [PATCH 6/6] misc: fastrpc: avoid duplicate DMA mappings in fastrpc_create_maps() srini
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=20261127104354.8452-2-srini@kernel.org \
--to=srini@kernel.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tyler.baker@oss.qualcomm.com \
--cc=vinayak.katoch@oss.qualcomm.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