From: netdev-bot+sashiko@kernel.org
To: elkin@google.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, nathan@kernel.org,
horms@kernel.org, ndesaulniers@google.com, morbo@google.com,
justinstitt@google.com, oss-drivers@corigine.com,
netdev@vger.kernel.org, llvm@lists.linux.dev,
linux-kernel@vger.kernel.org, irogers@google.com,
stable@vger.kernel.org
Subject: Re: [PATCH net] nfp: fix use-after-free in nfp_ccm_mbox_skb_return()
Date: Thu, 26 Nov 2026 22:19:38 +0000 [thread overview]
Message-ID: <179573157826.3135.7446124224703168884@kernel.org> (raw)
In-Reply-To: <20261125221658.1420387-1-elkin@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 1 · High: 0 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Critical] The patch is incomplete.
--
nfp: fix use-after-free in nfp_ccm_mbox_skb_return()
This commit changes nfp_ccm_mbox_skb_return() to save cb->err in a local
variable before the skb is freed. Before the change, cb->err was read
from skb->cb after dev_kfree_skb_any() had already run.
> diff --git a/drivers/net/ethernet/netronome/nfp/ccm_mbox.c b/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
> index aa8aba4ff7aac..c0f1d84208a41 100644
> --- a/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
> +++ b/drivers/net/ethernet/netronome/nfp/ccm_mbox.c
> @@ -420,10 +420,11 @@ static void nfp_ccm_mbox_run_queue_unlock(struct nfp_net *nn)
> static int nfp_ccm_mbox_skb_return(struct sk_buff *skb)
> {
> struct nfp_ccm_mbox_cmsg_cb *cb = (void *)skb->cb;
> + int err = cb->err;
>
> - if (cb->err)
> + if (err)
> dev_kfree_skb_any(skb);
> - return cb->err;
> + return err;
> }
[Severity: Critical]
Is this fix complete? This change makes a non-zero return from
nfp_ccm_mbox_skb_return() mean the skb has already been freed. One
caller still frees the skb again after that return.
The in-progress branch of nfp_ccm_mbox_unlink_unlock() passes the
helper's result straight back:
drivers/net/ethernet/netronome/nfp/ccm_mbox.c:nfp_ccm_mbox_unlink_unlock() {
...
if (nfp_ccm_mbox_in_progress(skb)) {
spin_unlock_bh(&nn->mbox_cmsg.queue.lock);
wait_event(nn->mbox_cmsg.wq, nfp_ccm_mbox_done(skb));
smp_rmb(); /* pairs with smp_wmb() after data is written */
return nfp_ccm_mbox_skb_return(skb);
}
...
return -ETIMEDOUT;
}
__nfp_ccm_mbox_communicate() treats every non-zero return as "the caller
still owns the skb":
drivers/net/ethernet/netronome/nfp/ccm_mbox.c:__nfp_ccm_mbox_communicate() {
...
err = nfp_ccm_mbox_unlink_unlock(nn, skb, type);
if (err)
goto err_free_skb;
return 0;
...
err_free_skb:
dev_kfree_skb_any(skb);
return err;
}
Only the -ETIMEDOUT branch, which unlinks the skb without freeing it,
matches what the caller expects.
Here is one sequence that seems to reach the double free:
1. A thread that is not first in the queue waits in
wait_event_timeout() with NFP_CCM_TIMEOUT.
2. Another thread's nfp_ccm_mbox_run_queue_unlock() adds that skb to
its batch and marks it busy with nfp_ccm_mbox_set_busy().
3. The waiter times out before the skb is done. It is still not first,
so it calls nfp_ccm_mbox_unlink_unlock(). nfp_ccm_mbox_in_progress()
is true, so it waits for done.
4. The batch fails in one of two ways:
- nfp_net_mbox_reconfig() fails and nfp_ccm_mbox_mark_all_err() sets
-EIO.
- nfp_ccm_mbox_copy_out() sets cb->err to -EIO or -ENOENT.
5. nfp_ccm_mbox_skb_return() frees the skb and returns the error.
6. __nfp_ccm_mbox_communicate() jumps to err_free_skb and calls
dev_kfree_skb_any() on the same skb a second time.
The commit message says this fixes the free-then-use of the skb around
nfp_ccm_mbox_skb_return(), but that path is still reachable here.
Should the skb be freed in exactly one place? Either the in-progress
branch could leave the skb alone, or the caller could return the error
directly instead of going to err_free_skb.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125221658.1420387-1-elkin%40google.com
prev parent reply other threads:[~2026-11-26 22:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:16 [PATCH net] nfp: fix use-after-free in nfp_ccm_mbox_skb_return() Elkin Cruz
2026-11-26 22:19 ` netdev-bot+sashiko [this message]
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=179573157826.3135.7446124224703168884@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@google.com \
--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