Skip to content

Fixes for crash seen in fastrpc testcases. - #1612

Merged
Salendarsingh Gaud (sgaud-quic) merged 2 commits into
qualcomm-linux:qcom-nextfrom
sgaud-quic:rb4_fastrpc
Dec 2, 2026
Merged

Salendarsingh Gaud (sgaud-quic) merged 2 commits into
qualcomm-linux:qcom-nextfrom
sgaud-quic:rb4_fastrpc

Conversation

@sgaud-quic

Copy link
Copy Markdown
Contributor

fastrpc_context_schedule_put_work() guards the once-only schedule_work()
with fl->lock. That helper is called from fastrpc_rpmsg_callback(), which
runs in hard-IRQ context on the glink rx interrupt, while every other
user of fl->lock takes it with a plain spin_lock() in process context
with interrupts enabled.

If the glink interrupt fires on a CPU that is already holding fl->lock,
for example fastrpc_context_put_wq() -> fastrpc_context_free() or
fastrpc_free_map() running in a kworker on that CPU, the handler spins
on the lock the interrupted code holds. The holder can never run again,
so the CPU hangs with interrupts masked, an RCU stall is reported for
it, and the system is eventually reset by the watchdog. It is easy to
hit because schedule_work() queues onto the local CPU's worker pool, so
the worker that takes fl->lock tends to run on the very CPU that
receives the glink interrupt.

The same helper is also called by fastrpc_notify_users() while it holds
user->lock, and ctx->fl == user, so a context left on fl->pending or
fl->interrupted when the channel is removed deadlocks on the same lock
there too.

The flag is only used to make sure put_work is queued once, so no lock
is needed. Turn it into an atomic_t and claim it with atomic_xchg().
Whichever caller sees the old value 0 queues the work; any later or
racing caller sees 1 and does nothing. This makes the helper safe from
hard-IRQ context and with fl->lock already held.

Link: https://lore.kernel.org/all/20261127-fix-put-work-irq-deadlock-v1-1-3aa66fe4f2c9@oss.qualcomm.com/
Fixes: 3f645f6884b5 ("misc: fastrpc: fix context leak and hang on signal-interrupted invoke")
Cc: stable@vger.kernel.org
Tested-by: Shawn Guo <shengchao.guo@oss.qualcomm.com>
Reviewed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
The put_work_scheduled field was converted to atomic_t, but
fastrpc_notify_users() still accesses it directly as a boolean. This
results in build errors due to the incompatible atomic_t type.

Use fastrpc_context_schedule_put_work() to atomically test and set the
state before scheduling the work.

Fixes: qualcomm-linux#1606
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
@qswat-orbit-external

Copy link
Copy Markdown

Merge Check Failed: No CR Numbers Found

Error: No Change Request numbers were found.

Please add Change Request numbers to your pull request description in the format CRs-Fixed: 12345 or link GitHub issues that are associated with Change Requests.

@sgaud-quic
Salendarsingh Gaud (sgaud-quic) merged commit 27cd2ba into qualcomm-linux:qcom-next Dec 2, 2026
1 of 4 checks passed
@qualcomm-ossops

Copy link
Copy Markdown

VSF scan completed: no known CVEs found in the files this change touched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants