From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408487; b=jj7m1YP57U/h13/MRlhWEYmZ6wa+qNXhFZoIDk0LiytVtlG2bFGI0/pYAj+p1kxxXMKp eXeQxW9+HDKdRXpM3GZ4MLtptYsOAOoOidLsv+wcE8QpXhdCM1NwZLxIXI/TZ8B5q3z/2 ghDIIcqECWFosPAgKWmX2wJzO6flNxjGdO7aXSLUeApGsluVNeIsbWA4szRy+2fKISBC5 IQLihlUL/cRWoZBSDzP/osSOJlGCh1+1hecb8+LqpkrwqLD+QMlslH3/GRkyJqccK6BtY irsCm5t8wRz/Z9rhRHxQt3O7F71Fcw5Kg70a+bDlyHZyUFFqdX5KlJehYPRu+jwoHFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796408487; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=J27wTgb5fgoizI3nZ3PisaICN/mRya18fH/Jz/zA2TQ=; b=lJEp6P1M9TAVRsWGgwn4s58hySilBmBHti/+0og5ZE9LtOcBu74ZOWGxP853ZSqA2R0q 0TSGi8VzbCFmFjC/K6wQSxCfIgMzbwhq5+Xp/feCqo0rc+/mFGLY1XO7KyGKKk5Q4f3Va tCuFNAQ1Wto1KbcC1tdJGJEEnr7Cic90GV2d/WvfC7vteh5AQZTe+Mvucq0V6eOe9TXuN kXsH0HKCP3tN30N9gJ2ixpJR+RoWkm67faNyXzffos6iE4coOavMOsNFE0JPL368ucIZP udC3wTqaYgq2yHXqSEuFy7SKJwYA1L9CEm24xO7wqWecdZii4ANtYxp5Ce2sFRYPEAg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--elkin.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="L5J/HCEE"; arc=none smtp.remote-ip=209.85.161.70 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACE4E606A681 for ; Fri, 4 Dec 2026 18:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ACE4E606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elkin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=L5J/HCEE Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-71be386bb06so1543182eaf.1 for ; Fri, 04 Dec 2026 10:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796408486; x=1797013286; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=J27wTgb5fgoizI3nZ3PisaICN/mRya18fH/Jz/zA2TQ=; b=L5J/HCEE54yrjmeWKvzzO+w2ILEcEOpYs8j+bYLk6GN//DF40PPBTkCC9p992xlak8 o29oKRFWMopx3nhq1O+l1ClfCi2IWIg3kgbeGcwZfW+9sccmSXrTSGpqZfpmCsrPjnPe 33OTw7iJPwwTbxzRtiRgED542lwWXWfpEJM4MuBzURxc0syCUsGhzLAYK86yv3bWNy7/ vS1sHHefY2cY3b9Hy7Eg6MrKRjWohNtTj13rDdruhIXNXMobP/OamX9a/s6ZxavSewUx mx3F/jsRsGD6Z2Oixi+rjlaB0TZdQY4Rp+1bclyPC9TlE/V5YQL8HUS1mGy1eBt7jBzL CFug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796408486; x=1797013286; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=J27wTgb5fgoizI3nZ3PisaICN/mRya18fH/Jz/zA2TQ=; b=PB1pfhUtN9VodetS+kY/rGqHE4mkrNo+FhIGsE/WP5ji45sX77OXfnkCd5oi3thdk9 DUehth5mojLo23MMj/JSFf2jIEda/+dB1GigF2S5Hk2lLHnE0VOFQkStq53x1FNlCmAV WbylvcjLCX8woGk+zL6/7T6TmWpj7cc5EqHO4vVQzqIwnE0mEYHgyzqnhbqb1c+W57iI On6BZ0hczAkc0rb06qDib62FSkKsNQrtunSOdkbBOzIvurXAS35fqQ6FKPPM2m4RIOxD eWeGJcgDjzpAqobfM78QhZJEuy6nKgp09IHRhLGN7urIRxdGAxBMWpehzzSha76PToXU amsg== X-Forwarded-Encrypted: i=1; AL+hErG2fjTMBc8dbKiaTDYgnV5Z4C73x927nCukdME8lpfKXxoukZ2fS6EawjoqKpAunEOsb2TY@lists.linux.dev X-Gm-Message-State: APuU4Z+HHwWazPhIo4nT8yXKAsLexO0N+ufOI9d1hRRrdpcRDFfmyzJ2 KBgMxj/np9mQDDCTw9/ohrL/JZK+LAQB0yZ3j+8CvRndchCIdbXtjf3QDKF8eRhj5jIAgjZn9oF 1yQ== X-Received: from oats15.prod.google.com ([2002:a05:6871:ec8f:b0:45e:e833:abd7]) (user=elkin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:f001:b0:71a:ecfc:4434 with SMTP id 006d021491bc7-71bf207e470mr2400104eaf.61.1796408485458; Fri, 04 Dec 2026 10:21:25 -0800 (PST) Date: Fri, 4 Dec 2026 18:20:34 +0000 In-Reply-To: <20261204182035.364657-1-elkin@google.com> X-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261204182035.364657-1-elkin@google.com> X-Mailer: git-send-email 2.56.1.987.g2ec0ab4260-goog Message-ID: <20261204182035.364657-2-elkin@google.com> Subject: [PATCH net v2 1/2] nfp: fix double-free on timeout in __nfp_ccm_mbox_communicate() From: Elkin Cruz To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor Cc: Simon Horman , oss-drivers@corigine.com, netdev@vger.kernel.org, Nick Desaulniers , Bill Wendling , Justin Stitt , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, irogers@google.com, Elkin Cruz , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- 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