From: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
To: Srinivas Kandagatla <srini@kernel.org>,
Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
Cc: Anandu Krishnan E <anandu.e@oss.qualcomm.com>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, stable@kernel.org,
Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>,
quic_bkumar@quicinc.com, quic_chennak@quicinc.com
Subject: [PATCH v4 0/3] misc: fastrpc: fix context leak and hang on signal-interrupted invoke
Date: Tue, 17 Nov 2026 15:09:44 +0530 [thread overview]
Message-ID: <20261117-interrupted-invoke-v4-v4-0-2320a8a7eda2@oss.qualcomm.com> (raw)
This series fixes a context leak and DSP hang that occur when a
fastrpc invoke syscall is interrupted by a signal (patch 3), plus two
independent, pre-existing bugs the refcounting audit for that fix
surfaced along the way (patches 1 and 2).
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
Changes in v4:
- Split the single patch into a 3-patch series. Patches 1 and 2 are
standalone, pre-existing bugs the refcounting audit for this series
surfaced - dead code in fastrpc_user_free() and a worker-reference
leak on SSR for ordinary (never-interrupted) pending contexts - each
with its own Fixes: tag, landing ahead of the actual
interrupted-invoke fix in patch 3.
- Fixed a hang inherited from v1-v3: fastrpc_invoke_send() failure
shared the same bail: label as a post-send wait interruption, so a
message that rpmsg_send() itself never delivered to the DSP could
still be parked as resumable, and a retry would then wait forever
for a response that was never going to arrive. fastrpc_invoke_send()
failure now gets its own dedicated cleanup path instead, without
needing an extra flag to tell the two cases apart.
- fastrpc_device_release() now also accounts for a successful
fastrpc_release_current_dsp_process(): if the DSP confirms it is
done with the whole process, the worker reference on any parked
context is dropped immediately instead of always waiting for a
later event.
- fastrpc_user_free() no longer unlinks fl from cctx->users
unconditionally at fd close; it now does so only once fl truly has
no references left, so a context still awaiting a DSP response
after fd close remains reachable by a later SSR.
- Extended the same unreachable-orphan fix to timed-out kernel
invokes (-ETIMEDOUT), which had the identical problem on
fl->pending.
- fastrpc_context_restore_interrupted() now uses kref_get_unless_zero()
when reclaiming a matched context on retry, closing a race where a
concurrent drain (SSR, fd close, or a delayed DSP response) could
already have dropped the context's last reference and be waiting on
the same lock to unlink it.
- Link to v3: https://lore.kernel.org/all/20261002-anandu-fastrpc-interrupted-invoke-v3-v3-1-31e90439d2ba@oss.qualcomm.com/
Changes in v3:
- fastrpc_context_save_interrupted() no longer drops a reference when
parking the context, fixing a kref double-put that left the context
under-refcounted.
- Restoring an interrupted context now matches on both handle and sc,
not sc alone, so a stale/differently-shaped retry cannot be handed a
buffer layout it didn't allocate.
- A mismatched handle/sc on retry now falls through to allocating a
fresh context instead of returning -EINVAL, so a thread issuing a
different call after an interrupted one is never permanently
wedged.
- Added a put_work_scheduled flag, checked and set under fl->lock, to
guard against fastrpc_notify_users() and fastrpc_rpmsg_callback()
both scheduling put_work for the same context.
- fastrpc_device_release() now drains fl->interrupted and drops the
invoker's reference on each parked context before releasing its own
reference on fl, fixing a leak of both fl and the context if the fd
is closed while a context is still parked.
- fastrpc_device_release()'s and fastrpc_user_free()'s drain loops now
use list_del_init() instead of list_del(), avoiding a poisoned-node
list_empty() check in fastrpc_context_free().
- fastrpc_invoke_send() can return -ERESTARTSYS from rpmsg_send()
itself before the message is ever delivered to the DSP. This is now
distinguished with a `sent` flag so only a completion-wait
interruption after a successful send is parked as resumable.
- ctx->args is now repointed at the retry's args on resume instead of
pointing at the original call's already-freed buffers; an
args_owned flag lets fastrpc_context_free() free ctx->args if a
parked context is drained/abandoned without ever being resumed.
- Link to v2: https://lore.kernel.org/all/805d5de8-477c-41e9-b192-d889d1cca9b6@oss.qualcomm.com/
Changes in v2:
- Fix kref imbalance: fastrpc_context_save_interrupted() now drops the
extra reference taken by fastrpc_invoke_send(), so the worker's put
correctly reaches 0 and triggers context_free.
- Fix -ETIMEDOUT context leak: remove the ETIMEDOUT exception from the
bail path so timed-out kernel invocations go through the same
list_del_init + context_put cleanup as all other error paths.
- Fix dangling node: fastrpc_context_free() now calls list_del_init()
under fl->lock before releasing resources, preventing a dangling node
in fl->interrupted if a racing channel removal fires put_wq.
- fastrpc_notify_users() now calls schedule_work(&ctx->put_work) for
interrupted contexts to drop the worker ref on channel removal.
- Add dev_warn() on TIMEOUT and ERESTARTSYS for post-mortem debugging.
- Use list_del_init() instead of list_del() in the bail path.
- Link to v1: https://lore.kernel.org/all/20260525124222.3082420-1-anandu.e@oss.qualcomm.com/
---
To: Srinivas Kandagatla <srini@kernel.org>
To: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
To: Arnd Bergmann <arnd@arndb.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@kernel.org
Cc: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Cc: quic_bkumar@quicinc.com
Cc: quic_chennak@quicinc.com
---
Anandu Krishnan E (3):
misc: fastrpc: remove dead context drain in fastrpc_user_free()
misc: fastrpc: drop the DSP-response reference on channel removal
misc: fastrpc: fix context leak and hang on signal-interrupted invoke
drivers/misc/fastrpc.c | 187 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 146 insertions(+), 41 deletions(-)
---
base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4
change-id: 20261117-interrupted-invoke-v4-f2e5be78eba8
Best regards,
--
Anandu Krishnan E <anandu.e@oss.qualcomm.com>
next reply other threads:[~2026-11-17 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:39 Anandu Krishnan E [this message]
2026-11-17 9:39 ` [PATCH v4 1/3] misc: fastrpc: remove dead context drain in fastrpc_user_free() Anandu Krishnan E
2026-11-17 9:39 ` [PATCH v4 2/3] misc: fastrpc: drop the DSP-response reference on channel removal Anandu Krishnan E
2026-11-17 9:39 ` [PATCH v4 3/3] misc: fastrpc: fix context leak and hang on signal-interrupted invoke Anandu Krishnan E
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=20261117-interrupted-invoke-v4-v4-0-2320a8a7eda2@oss.qualcomm.com \
--to=anandu.e@oss.qualcomm.com \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jorge.ramirez@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_bkumar@quicinc.com \
--cc=quic_chennak@quicinc.com \
--cc=srini@kernel.org \
--cc=srinivas.kandagatla@oss.qualcomm.com \
--cc=stable@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
all inboxes | Powered by JetHome®