From: Elkin Cruz <elkin@google.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Nathan Chancellor <nathan@kernel.org>
Cc: Simon Horman <horms@kernel.org>,
oss-drivers@corigine.com, netdev@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
irogers@google.com, Elkin Cruz <elkin@google.com>,
stable@vger.kernel.org
Subject: [PATCH net v2 1/2] nfp: fix double-free on timeout in __nfp_ccm_mbox_communicate()
Date: Fri, 4 Dec 2026 18:20:34 +0000 [thread overview]
Message-ID: <20261204182035.364657-2-elkin@google.com> (raw)
In-Reply-To: <20261204182035.364657-1-elkin@google.com>
When wait_event_timeout() expires in __nfp_ccm_mbox_communicate() and
the message is not first in the queue, nfp_ccm_mbox_unlink_unlock() is
called to handle timeout cleanup. If another runner has already picked
up skb (nfp_ccm_mbox_in_progress(skb) is true), it waits for completion
and calls nfp_ccm_mbox_skb_return(skb), which frees skb when cb->err is
non-zero.
__nfp_ccm_mbox_communicate() then checks the returned error and jumps to
err_free_skb, freeing skb a second time.
Give nfp_ccm_mbox_unlink_unlock() the same ownership contract as
nfp_ccm_mbox_skb_return() (free skb on any error, keep it on success) by
freeing skb before returning -ETIMEDOUT, and return its result directly
from __nfp_ccm_mbox_communicate().
This issue was flagged during the netdev Sashiko AI review of v1 of this
series. The finding was triaged and fixed, and this commit description
was drafted with the help of AI, then verified by code inspection and
compile-tested against linux-next (not reproduced and not runtime-tested
on hardware).
Fixes: d3e4dfe060cc ("nfp: add support for sending control messages via mailbox")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
drivers/net/ethernet/netronome/nfp/ccm_mbox.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/ccm_mbox.c b/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
index aa8aba4ff7aa..86d2569ff176 100644
--- a/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
+++ b/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
@@ -457,6 +457,7 @@ nfp_ccm_mbox_unlink_unlock(struct nfp_net *nn, struct sk_buff *skb,
nn_dp_warn(&nn->dp, "time out waiting for mbox response to 0x%02x\n",
type);
+ dev_kfree_skb_any(skb);
return -ETIMEDOUT;
}
@@ -576,10 +577,7 @@ int __nfp_ccm_mbox_communicate(struct nfp_net *nn, struct sk_buff *skb,
if (!nfp_ccm_mbox_is_first(nn, skb)) {
WARN_ON(!to);
- err = nfp_ccm_mbox_unlink_unlock(nn, skb, type);
- if (err)
- goto err_free_skb;
- return 0;
+ return nfp_ccm_mbox_unlink_unlock(nn, skb, type);
}
}
--
2.56.1.987.g2ec0ab4260-goog
next prev parent reply other threads:[~2026-12-04 18:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:20 [PATCH net v2 0/2] nfp: fix double-free and UAF in CCM mailbox error paths Elkin Cruz
2026-12-04 18:20 ` Elkin Cruz [this message]
2026-12-04 18:20 ` [PATCH net v2 2/2] nfp: fix use-after-free in nfp_ccm_mbox_skb_return() Elkin Cruz
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=20261204182035.364657-2-elkin@google.com \
--to=elkin@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=irogers@google.com \
--cc=justinstitt@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@corigine.com \
--cc=pabeni@redhat.com \
--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