From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408487; b=j8EzzBmTtZVraRsjBAKpar4wSd4WZQloaZVSrND/HkFv6a4G/khh8LzdThTy4QA6dsCA defH0VWEyjtWM/+4kSYKsJ14AAmH/d9juKf04gqwW5+nO9JDLtbmPxx7goG980SfgDcri 9zL7gPueS2vj+GqrPJmaIg5dlenD3k61TRBbZzkSvCxyyRxyLBtmKe6lBYGSa7LpNR4wB uoEOfJHqrbJiM53uqqsscNq5AdE/7c3NfOVsO3ov+Wxg75tFqDql+LRVpMZQWkO2ZyVct DOvKuB+Uv9GqACMPjc4y7bO4ysO1XW1GtUVwvo7Ar2Z7XTSd8f8JKS9dSlSKMa/obgw== 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=SUWhxZieq7tKDjHqiZpEHGl9Szuoa8NHbXRAPuh2Ti1MCwKF3IlZJHhRWBKg63kW/pd2 WiKYd+cZlQbLXtxMdff7bJ8AmoZChVid3Ighcdeatw9UyrIS6hmr1+B7VQ7uLxAQXop8P TLvYyHVUunkbPv1wYdOIQSVL16DmfCr9CbtDyDwL2yn8knoBAiUnohioxkUOYvU1N8JSI aOD6SQTJMrNZrvfKeFoiFRftfoESBIVt7lEJ/O/PGYai1n3z9GCXb2eyXTxlGer0CvReY vTVUFLR5aZRbf1GjWJiUJ/3+rZHjwGhTpJSdqVzcyEYqlDgYSwIr8xZodgMiSx9ZFxA== 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=kztanJjk; arc=none smtp.remote-ip=209.85.210.70 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.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 A94B7606A33E for ; Fri, 4 Dec 2026 18:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A94B7606A33E 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=kztanJjk Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-8628955a085so1288821a34.3 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=vger.kernel.org; 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=kztanJjkZgb+UrsTlzCLA4DPQxgXE3f79BYMyhKBO+83dcpkm+6+7pPgHt8FTxNRl4 gvA+suXeVwzwHI3HPXJEKLoxciB2VONPChnVWejazn7MDqUDr0Tp7TU/I8PQW/0YMHQE eVq2m0osDtxgJVO18/URvHV+B4RWH4f5ZTNWXsK8+Nj6SOi5uXv+rabHuhyyeuHitVJz ljRYNbcdbg0wce5h58LEuZKAQ1zZSUVM15UU4J/4uyuorFhjOdkdDdEjEleXRGZMG2YB bFmTcXxbI2Z6MZwyR2k2aUiuyevdkPgjI/PQG02T8YoqjHmkfG0TD/Saanwe0spR9DOd TjJg== 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=n0CjvMUZO8y87zMe+CztcdFcoh1AOomvLJnBjsUcs9okkurcVNwjbkq8XFRuC8k7Fu xA25gIElL4QvB6EfVLfDGWq4DBOlc40CQ6gkdKNuOYBYqhlT6CM4RYo/ijHEuk6ZYlD2 bHB+moh8g+lCyeYRddw1uA1romkKbMaLct/Z5Hd0cVFK7VAFRG7wSiBQJfDb6U7gED9J wLnHXJOYD3jLOXfK4MFORcg5qyDFDmwcYo2thAhRIuU6tpI4/hy6HaWOvXuKOldVe9Pc xIEANiN8x36fIGHWV9BgXHKGhKrqjOGdb7kyPeUSlObIX8XHnxGnWjJBybE+PCcAUb1H JWDg== X-Forwarded-Encrypted: i=1; AL+hErG57C+b51FUZyr1tZ4Af14NvBohepfZN7oXFKqJG8ezbkz4S1Pmazdw/IB7qvaH/ctxLs+y7rE=@vger.kernel.org X-Gm-Message-State: APuU4Z/xsxzA0yaz6GxVBQoFg+uHqq2MzZEIjeUWoZsjPeO7IHcXPz7j AwxIPEo7KWb/XmDUTPk323Hw/N97JFMY78F50EwjnLGQ9b97pxPAxTIYBDhBq/YUpD2lLqsXgEP xyg== 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: netdev@vger.kernel.org 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