Article View: linux.kernel.netdev
Article #23257Re: [PATCH net] nfp: fix use-after-free in nfp_ccm_mbox_skb_return()
From: netdev-bot+sashiko
Date: Thu, 26 Nov 2026 22:19
Date: Thu, 26 Nov 2026 22:19
110 lines
11703 bytes
11703 bytes
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
Technical Details
Message-ID:
<179573157826.3135.7446124224703168884@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372374-linux-kernel-netdev=dewy.ruReferences:
<20261125221658.1420387-1-elkin@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372374-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] nfp: fix use-after-free in nfp_ccm_mbox_skb_return() Date: Thu, 26 Nov 2026 22:19:38 +0000 Organization: Usenet Network Message-ID: <179573157826.3135.7446124224703168884@kernel.org> References: <20261125221658.1420387-1-elkin@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="580802"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:sRim169PO5u9o73WNFVNMcRA6lE= sha256:y5DDN31lXWmVPFgmofDhjsnz7Sbq6+g0dNgjBg5mvFw= sha1:POGznBYoQZfm8PLY5HafifoJ+2E= sha256:BkgnpyyIpC+JkhW2AykCyGq16eq14q+dDs3fPMgWQLA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 327EF125F0C; Fri, 27 Nov 2026 01:20:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sy8P_ZEZJkh3; Fri, 27 Nov 2026 01:20:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372374-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 24131125F04; Fri, 27 Nov 2026 01:19:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BB85F3633E; Thu, 26 Nov 2026 22:19:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795731581; b=sZpw4NyMS+BSPDg8x8GouK9ayQa65FqgxR4aUbA7NinXAEMapvUAo3hPIoz7o59ZT/6T 4q/yjB/iWSjGnFdNrfdhFWvG8vOBcPxeMkQckz8oc2h+R/W8eoxzYMIXuxWYE4NR5sIDl ytrbPsT+NZUZFtSam6oiVHR06n73ip4/AxD5+wrZog36ENgH6qQgGzPfwr3Q8jGDf6628 KWfcT8llCkpZillQEtGTqgS58mhtTsoEtCxBDQVxEvN2nxB5/oxtOys3vh3PbkARPLStv STAiCXfn/PjBBLnfujngK05JaZyAsX/G7xTxF1nkugg+6B4Ts4Ibe7YcE/EJvr8EKrQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795731581; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=78fWkS2YWTJb7t6FsSnWQIR2C3mUObK3JQjnGJfkMvk=; b=VrLyvco1kOC79KuzXFwh95w0kSyXDyHPiKhcCDBX2Hw2aFglnR+uQs6Fj1xSw0uov7vh QLhsxwD1bO+S8EdfKp7uKoHc+PcNJSBvoUIZf8DVfsJg6M70TLbihYP5risfchzMAzouu LBORtKSnKxXmBeoOpcfygISmN5chNQbotMFyq3h7xHAXBBC0VAkLv+wJq8YuOAFDcFAZW 2aMW66wJKxAkXz4xUEjxG80vbwkTK7lUGM+uH+M9w0E974mhWlZutX0PLCko9sEjFVIj4 bkV6PhOGGf3OGxS/K4HoHSrF0wA+8wEI6KMvqE+GzTuBfJ8YvoYXDbIgQids+eQb+bA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SIYaOhvH; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 338B8606A321; Thu, 26 Nov 2026 22:19:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SIYaOhvH X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795731580; b=M7Ym4b579K4GCgqmgNOGBQLlK/AVt+R4zqOeM+4monOeObz5k3+QKylosXzxl++/zTgb XzkRZUtg+l2M/hDpdcZpkmxgCOtBglAmY/IM0l97/ov/Dy9PPnsfh/lOe5YdMquhoYr9S s/krDxdQHP+1nfkxpQUkkJoUTE6gwzcO9hCrRlAAeuBXWq+CqsTZAzVLWuLHEgD4KF5XF 4dyBL1Sl5HR7juFNi5NpBV9I0F5bHFGcN86Zlgxs4G/RK7q3+mVCVWyzYJdQHdVt/xS+i EWYs1mpqxMNDvAJN/zkoW6SS8+DwgPB9cEoudN+YULUlht2VYaUaviqYdFn1l0oKUDQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795731580; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=78fWkS2YWTJb7t6FsSnWQIR2C3mUObK3JQjnGJfkMvk=; b=MLpP1UJAzsm7pBt2ms22uxJjM3Dc7dg0fr9lnW9PZeqwANcp6GovkG0S2IZeqoFqVFRT 2ym54AnvKz4YYu2VqXk/naV7obA9oqfHoziAK0xZusxl8kxsXY7z83lQaA1tkRuGExgiP QRhYv51PLY4k03mKPY/bOoQ9lO3F28oXkQIJqfW29NqTfkQGYfc/erNksyY5TmXbWzVhH Q52xeLobQervjXF5KMQhbN+jhNwVpMIU4IAwDVoRUIPNtTNOfwgTa9XKr1XIntVtl6bTx w/1HbRkC5OcV+VMF+6oD979BdguYYSLndLGAzTKeXDSdUHhY0pczmeEE8PM9bD4JPyg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SIYaOhvH; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5488C606A335; Thu, 26 Nov 2026 22:19:40 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B69931F0092B; Thu, 26 Nov 2026 22:19:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795731579; bh=78fWkS2YWTJb7t6FsSnWQIR2C3mUObK3JQjnGJfkMvk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SIYaOhvHubijw0//5Ald1UPP9Da3ycPrlm2agZYi21s4nFc0BE/ur1u70D2ASGZIc A23RjMqpX1rsBR+2L7sHx0KAimGidZZvqeTbwldK53qZUk6d8ieTRx3VQRiXhMSdBu tHDBal2n6L0e1XJ59ZvwT6rNN/y7H6YPKLrYxL+6Gr+BASuRulu5No1o4KsBX+mrBd JA/dr9mZoYtqihELA9tbr1z4k5pewQlqpNaU2VVxP+hZOGLbVUM3snwjkeFXlKaDse aS52ZVxQsEtpDmZclS18FpwabGOi1AULw3XWKwP6N8idY78sw6xKiDrQ1XOdY+PiQ/ dxjJvKcRYrorg== X-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 X-In-Reply-To: <20261125221658.1420387-1-elkin@google.com> X-sashiko-severity: Critical X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list