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=PGbCKhYRciGukoMPvD+fw3imNKGsoiDs92X8z0bhTYC6t/KOSISISH3Un5Htv1ULlpsg j6b8vRjzrhAVMSsLdbmvn5pEEClz4FlJ2A+Gzkhj2/W3tJRqNDKRLK7l9PLKqroyRk/Bf BCa7APMT1RGFNeVJOj5qoYYg4zK5kcg/y7uyU0yGdSQ+15k4vBmFIpFZXOijHVY40BC23 pyyxB4XT6njfSK4SVSw54A22IbV5DqCq3iPRUWT20MUGKhZbizDctb8xyjct6cvD75kWH Dmv0k0c1IyPDX+yReVJBQZduH2iL60MneTTJ8cNDnHHUcpcbMQXeQfoRTyu68U+8dXA== 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=E9NkSF50PPjYD+JrUe8nr4ENDrORh+hXqsxIEI6cyYlVAx+/lxay+t5pxetHHgzKy0pV s5NyYj4ke7hKihAdFzwSYYMT3+Dtj0OBt1GolXmfaRZ9z7GvgnTqA+0drIvZGBUxJ3Jui hzOgopfBnEhGcwPTWPr3YvzPDcf9dBeN9n6XSIHaOOD5hEAWtbL2OTxp4m3OZvv3kgdge 19N+/rzbQT4AloZRe8Yi2y8aBsiIt9eGHAT+UgUx7mbjPAWCuN/bsxrne7A5DmnemP8S4 TzzqBoOfRGSRVPDVrcyUa7HAOQEZDJrQ5QSxU/1kDpw/K9uue4sfCDkmwyZrN2fx+nw== 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.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 ACFA5606A682 for ; Fri, 4 Dec 2026 18:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ACFA5606A682 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-oo1-f70.google.com with SMTP id 006d021491bc7-6dd1142710fso1138623eaf.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=yCRYg0M/PjUYfkK81uWlNPlPa3A2B3GVRRXniNie7PwNTJ0846IhBcGxk4iOLLrCVF cfLWJgX7j6HG2a5h79SgT4tIdVuP+nuJCaWAtojJJEGn3g4sICqgLNuqaHnIPJ4mD+p5 5cMjMvFK+m5ZJjmQeYuZvdUUx2YGko8J0qCZ/S4GbHWODS/rqkfNn2n3ynVAvzRKDJ0m c5zKRKy4jrcguqC+pKvylJV69j1i31UTqjqaGufeCDwbBa9AhIjvS9P/Roe/EU8nG5Ze vtlA1Fd5JsNXqgk1odzYMC5IqK2pkP4bfm9i+YrzB2r3YuBRS1y+fwyivlLC9lPpn822 Fg0A== X-Forwarded-Encrypted: i=1; AL+hErHw5zYBNW0PGgvgX2pl5RECzKZidiMXjG3eqiWAEouZorh1sgs4N/azcP8piHSnUPyWXiAZ+io=@vger.kernel.org X-Gm-Message-State: APuU4Z8lYI7gK+q7STyVwjFyw5595rd0MIxfpeIdDOds20Dorls+LG1x ukz6O2K9b3K1FkBiNEG/eHqic8TWD/23ZMicMHYSfTAHxi57zqPN9QNm7OpFK9h0iCH21Sl8sC8 9xQ== 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: stable@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