Skip to contentSkip to conversation

FAILED: patch "[PATCH] 9p/xen: fix refcount leak in p9_xen_response() on wrong tag" failed to apply to 5.10-stable tree

PATCH New Sasha Levin 1 participant 2 messages Nov 10 – Nov 12

Subsystems (2)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 4d183e6f153245aca2534e372152583b868dd925
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 4d183e6f153245aca2534e372152583b868dd925 Mon Sep 17 00:00:00 2001
From: Yifei Gao <[email protected]>
Date: Thu, 6 Aug 2026 14:42:54 +0000
Subject: [PATCH] 9p/xen: fix refcount leak in p9_xen_response() on wrong tag

p9_xen_response() looks up the request for an incoming reply with p9_tag_lookup(), which takes a reference on the returned p9_req_t. When the tag does not resolve to a request in REQ_STATUS_SENT, the function warns and continues the loop without dropping that reference, permanently leaking the p9_req_t and its msize buffers. The reply header, including the tag, is supplied by the backend, so a malicious or buggy 9P backend can leak kernel memory on every crafted response.

Drop the reference before continuing.

Fixes 728356dedeff ("9p: Add refcount to p9_req_t")
Assisted-by Claude:claude-opus-4-8

Message-ID: <[email protected]>

---
 net/9p/trans_xen.c | 2 ++
 1 file changed, 2 insertions(+)
net/9p/trans_xen.c +2 -0
index f9fb2db7a0663..8eea0da8797f4 100644
@@ -203,6 +203,8 @@ static void p9_xen_response(struct work_struct *work)
 		req = p9_tag_lookup(priv->client, h.tag);
 		if (!req || req->status != REQ_STATUS_SENT) {
 			dev_warn(&priv->dev->dev, "Wrong req tag=%x\n", h.tag);
+			if (req)
+				p9_req_put(priv->client, req);
 			cons += h.size;
 			virt_mb();
 			ring->intf->in_cons = cons;
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/1 9p/xen: fix refcount leak in p9_xen_response() on wrong tag

From: Yifei Gao <[email protected]>

[ Upstream commit 4d183e6f153245aca2534e372152583b868dd925 ]

p9_xen_response() looks up the request for an incoming reply with p9_tag_lookup(), which takes a reference on the returned p9_req_t. When the tag does not resolve to a request in REQ_STATUS_SENT, the function warns and continues the loop without dropping that reference, permanently leaking the p9_req_t and its msize buffers. The reply header, including the tag, is supplied by the backend, so a malicious or buggy 9P backend can leak kernel memory on every crafted response.

Drop the reference before continuing.

Fixes 728356dedeff ("9p: Add refcount to p9_req_t")
Assisted-by Claude:claude-opus-4-8

Message-ID: <[email protected]>

[ sashal: changed p9_req_put(priv->client, req) to p9_req_put(req) to match the one-argument API ]
---
 net/9p/trans_xen.c | 2 ++
 1 file changed, 2 insertions(+)
net/9p/trans_xen.c +2 -0
index ff81b323ea7b5..d76da50c664c0 100644
@@ -233,6 +233,8 @@ static void p9_xen_response(struct work_struct *work)
 		req = p9_tag_lookup(priv->client, h.tag);
 		if (!req || req->status != REQ_STATUS_SENT) {
 			dev_warn(&priv->dev->dev, "Wrong req tag=%x\n", h.tag);
+			if (req)
+				p9_req_put(req);
 			cons += h.size;
 			virt_mb();
 			ring->intf->in_cons = cons;
Signature · 1 line
2.53.0