From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408487; b=xhQuktCTqC6pzvBUpiTlOBwPiOR6f36oWfQm2i0homHQDuEuYKgCx7ZiE2Y8A7KZs4aS 2FEZEJ4aDdep3kox/9/zJVB9rWysLOBu9P+iLLh22xlttckD5vgM4pO5f85UKOtZZBKmP qJmWeWNvs1h0uchvMNWu5+PGKcSHz6oR+TIsOYsd4fy0XTJyxBKhqdvj8nltHPY3MrzXr 00Yg4cxi2AxvLfXyuQg0iDWXGH5jLRNPsZm6eZ4g9p9/FuzKEQ6p5/rQWHbBj8npj9Lip g354xny9J4hpSk3UijPlrQsFsjlgWZzUDmf4OUqpI4WefVJGMcMVxZHeJUL0HnETppw== 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=11T/cR0mYzg7NJ2GpCuRkLKufmXrtMbfq4PEsRGpr7HQM9ZCMWj3nXHo2SngG6c0g6yL W76cYFNS1lIYEa2jvFEN/0H/S6cO3H4Wj6yJJm7j+c4iC0hFAzekN326uf6duNcCOX7cs qNT+MBbe92FDdJkK6iy1CRUogJCA1+LnWdsW/piNIbqBt0d8V2dDDPgx7JNBK6u7tDJr2 FHPTmBYMVtUhMx1sSGj5NUWb4k/33nY8c10GWvPTBS9qE2jeWNft6oBeBq0YOZ5zn0ez3 Mdr3GKnoVNlGPB++4/5NDvaYT6c/o83IG3tONeTz/cHmYsTJWYDcS854VZ9J6Vjc4WA== 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.71 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (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 B2DCB606A322 for ; Fri, 4 Dec 2026 18:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2DCB606A322 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-f71.google.com with SMTP id 46e09a7af769-86313f7f4faso1280971a34.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=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=KlW+/rLz+d4K0MMZ6wSPEhTUBm+3jdySfm5z1LyXRY5mbkrn9yw1IriUdKdomWF0ip t955g8ymJZ3ERf3DE7hGSgSUQRCz7AhE00mbg0KWYPgLRiYSbVVMa7W+viFNVaVam0ic ViFTHkuvKA8el6GepbMXI9PZRtQQOpe8SlfsjmycsDp1/UXXuzt+hqleyd0a1z66YnbG ygZD8UC4TAAB4naZ3agP02baHBWc0OAbFI9DFz361ZsZaUM3j6074TeBx3cI6samJgdh MFM/iiBLBhknFWtdvOY75irRu8q4ztGjFTrrgmPwBJ+MDF3VscetCccniqhJbgaJj2AO yQpg== X-Forwarded-Encrypted: i=1; AL+hErH76BFnBoZGREGmuDB0NGvj0sAQPPoU2rRcUUlt4EhLeoZRGjWCsz0bsVWINu+zE6hZ7xxSPCOb1K3xNRs=@vger.kernel.org X-Gm-Message-State: APuU4Z+mlzJeH4D3i4rae4nbbaLtiPAqo0u9UNODNDsGPpcpW+rqLCsQ +dSYTszJg57GPQXRVVWopx0zILT1YfQcv8TVqKQoZmht1mCv7UAVrqbDYOJVkl/0skJ/ngnfFym 1GA== 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: linux-kernel@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