From: bo cao <treebacker@foxmail.com>
To: srini@kernel.org
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
stable@vger.kernel.org
Subject: [PATCH v2 0/2] misc: fastrpc: context lifetime fixes on the glink response path
Date: Fri, 30 Oct 2026 16:51:48 +0800 [thread overview]
Message-ID: <tencent_AE37F59DA9A6DAB192F6BAFD054E584FAB05@qq.com> (raw)
This is the public follow-up to the report "fastrpc: use-after-free
of fastrpc_invoke_ctx on duplicate glink responses in
fastrpc_rpmsg_callback()" (source analysis of v7.3-rc5 and current
master), incorporating feedback from Greg KH on the originally
proposed single patch:
- split into two independent fixes, each with its own Fixes tag;
- the atomic bitop and flag bitfield are replaced by a plain bool
checked under cctx->lock, together with the sequence validation;
- brace and comment style fixed;
- kref_get_unless_zero() at the lookup is kept: the lock protects
the IDR but not the context lifetime, since the final kref_put()
runs outside the lock and fastrpc_context_free() removes the
context from ctx_idr only after releasing its maps and DMA
buffer, so "found in the IDR" does not imply "refcount > 0".
Patch 1 pins the context found by idr_find() before dropping
cctx->lock and runs the sequence validation inside the critical
section. Patch 2 makes the response path one-shot so a duplicate
response cannot consume the in-flight reference a second time.
No runtime reproducer is included: triggering requires a second
COMPLETE response for a live context, i.e. a buggy or hostile DSP,
which cannot be produced from the ARM side on stock firmware. The
sequence check added by 96e62cc0a84d already addresses the same
class of misbehaving remote responses (the recycled-IDR-slot case);
these patches close the remaining cases (duplicate delivery for the
same context, and the unlocked use against a concurrent context
free).
v2 is a resend of the two patches previously sent as two separate
emails, now properly threaded as a series with git send-email. No
code changes.
bo cao (2):
misc: fastrpc: pin invoke context at glink response lookup
misc: fastrpc: consume in-flight reference exactly once
drivers/misc/fastrpc.c | 40 ++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)
--
2.39.5 (Apple Git-154)
reply other threads:[~2026-10-30 8:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tencent_AE37F59DA9A6DAB192F6BAFD054E584FAB05@qq.com \
--to=treebacker@foxmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srini@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
all inboxes | Powered by JetHome®