mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
	Anandu Krishnan E <anandu.e@oss.qualcomm.com>,
	stable@vger.kernel.org, Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 3/6] misc: fastrpc: remove dead context drain in fastrpc_user_free()
Date: Fri, 27 Nov 2026 10:43:51 +0000	[thread overview]
Message-ID: <20261127104354.8452-4-srini@kernel.org> (raw)
In-Reply-To: <20261127104354.8452-1-srini@kernel.org>

From: Anandu Krishnan E <anandu.e@oss.qualcomm.com>

fastrpc_context_alloc() takes a reference on fl via fastrpc_user_get()
for the lifetime of every context, and fastrpc_context_free() always
unlinks the context from fl->pending before releasing that reference
with fastrpc_user_put(). This means fl->refcount cannot reach zero -
and fastrpc_user_free() cannot run - while any context is still linked
on fl->pending: whichever context's release happens to be the one that
drops the last reference has, by construction, already removed itself
from the list a few lines earlier in the very same call.

The list_for_each_entry_safe() loop over fl->pending in
fastrpc_user_free() can therefore never find anything to iterate. It
has been unreachable since fl's own lifetime was switched from
file-close-synchronous teardown to kref-counted teardown; it was never
updated to reflect that the list it walks is now guaranteed empty by
the time this callback can run. Remove it.

Fixes: e85eb5feca8e2 ("misc: fastrpc: fix use-after-free of fastrpc_user in workqueue context")
Cc: stable@vger.kernel.org
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
 drivers/misc/fastrpc.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 70b5642f5fbc..60c9d1d0834b 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -559,17 +559,11 @@ static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx);
 static void fastrpc_user_free(struct kref *ref)
 {
 	struct fastrpc_user *fl = container_of(ref, struct fastrpc_user, refcount);
-	struct fastrpc_invoke_ctx *ctx, *n;
 	struct fastrpc_map *map, *m;
 	struct fastrpc_buf *buf, *b;
 
 	fastrpc_buf_free(fl->init_mem);
 
-	list_for_each_entry_safe(ctx, n, &fl->pending, node) {
-		list_del(&ctx->node);
-		fastrpc_context_put(ctx);
-	}
-
 	list_for_each_entry_safe(map, m, &fl->maps, node)
 		fastrpc_map_put(map);
 
-- 
2.53.0


  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 ` [PATCH 1/6] misc: fastrpc: fix NULL rpdev dereference when session alloc fails srini
2026-11-27 10:43 ` [PATCH 2/6] misc: fastrpc: fix init ordering race in rpmsg probe srini
2026-11-27 10:43 ` srini [this message]
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-4-srini@kernel.org \
    --to=srini@kernel.org \
    --cc=anandu.e@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.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®