From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1126192B90; Mon, 20 Apr 2026 15:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776697847; cv=none; b=E+6njXbZBc7QTrjOPyXPR1XLsA6YO+LnQDZCyLFJt7uStZ7VbwssfutOVtqDP090dkqE0WeEp6lKHMM+TzKMfQR/wg+QTznq9YC6rzAu5tqXKjmGRnCwfSjw44cTLG/97nCpPPnKVko7Bg3ajpvxa4kWgBf8euE6ON7gtLo1DFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776697847; c=relaxed/simple; bh=Gq8V6Gavz28SXbmtLUZgwlaXcHxiOpo6jsxmlaqXFx0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bARVnsKFQhWNTArJrtFrA+evFiqjN8znrRSDOauPSLOCqDqgh/rGdfrWl/CuOOkq3aUNqBu4N6iowpetSEoni60G20eGMczm67GQtwomY0qwJPu7VzTqlUpdCTfXJjtQ2j+4lugDNDI8WU+RB0xNY3ZCYitw6EalTJvZ11elGZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CT+QsVhi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CT+QsVhi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F1DCC19425; Mon, 20 Apr 2026 15:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776697847; bh=Gq8V6Gavz28SXbmtLUZgwlaXcHxiOpo6jsxmlaqXFx0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CT+QsVhi3u66CIymCWsItF+xHphCD4o8p7jdDq1Wu2sHgDCZrW1/UiqRXvXZAQn18 /B/1XWHPDDs8WZmF5+cpXk0g1u9ejrQn/5BbJaMpOJjw03+kHmoXTFnROpYJSOEyMr wePFE4p0SOSD2njWpb3bLeN2Dt4wWBdrFjzihC3EI55MIW/3xKNrLj6cldpBvf8AYP xhYoBkXH6j5vyZk4Gor4RF1YQcC+FkjTDb4iTQFMgUADa4Rvsju5dKkp2KwPLMxrjs YPD37Glh1FvICXI6k0BTP4KkC/OGplSzCfXZQg6L3e1G6ZYd6+3fEERQO6qc1YJ4IY 1gb7GiSCT8AmA== Date: Mon, 20 Apr 2026 16:10:40 +0100 From: Lee Jones To: Tung Quang Nguyen Cc: Jon Maloy , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , "netdev@vger.kernel.org" , "tipc-discussion@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/1] tipc: fix double-free in tipc_buf_append() Message-ID: <20260420151040.GF3202366@google.com> References: <20260420130524.3527420-1-lee@kernel.org> <20260420143309.GD3202366@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, 20 Apr 2026, Tung Quang Nguyen wrote: > >> Subject: [PATCH 1/1] tipc: fix double-free in tipc_buf_append() > >> > > >> >The tipc_msg_validate() function can potentially reallocate the skb > >> >it is validating, freeing the old one. In tipc_buf_append(), it was > >> >being called with a pointer to a local variable which was a copy of the > >caller's skb pointer. > >> > > >> >If the skb was reallocated and validation subsequently failed, the > >> >error handling path would free the original skb pointer, which had > >> >already been freed, leading to double-free. > >> > > >> >Fix this by passing the caller's skb pointer-pointer directly to > >> >tipc_msg_validate(), ensuring any modification is reflected correctly. > >> >The local skb pointer is then updated from the (possibly modified) > >> >caller's pointer. > >> > > >> >Fixes: d618d09a68e4 ("tipc: enforce valid ratio between skb truesize > >> >and > >> >contents") > >> >Assisted-by: Gemini:gemini-3.1-pro-preview > >> >Signed-off-by: Lee Jones > >> >--- > >> > net/tipc/msg.c | 3 ++- > >> > 1 file changed, 2 insertions(+), 1 deletion(-) > >> > > >> >diff --git a/net/tipc/msg.c b/net/tipc/msg.c index > >> >76284fc538eb..9f4f612ee027 > >> >100644 > >> >--- a/net/tipc/msg.c > >> >+++ b/net/tipc/msg.c > >> >@@ -177,8 +177,9 @@ int tipc_buf_append(struct sk_buff **headbuf, > >> >struct sk_buff **buf) > >> > > >> > if (fragid == LAST_FRAGMENT) { > >> > TIPC_SKB_CB(head)->validated = 0; > >> >- if (unlikely(!tipc_msg_validate(&head))) > >> >+ if (unlikely(!tipc_msg_validate(headbuf))) > >> > goto err; > >> >+ head = *headbuf; > >> This is a known issue and was reported via > >> https://patchwork.kernel.org/project/netdevbpf/patch/20260330205313.24 > >> 33372-1-nicholas@carlini.com/ The author did not respond to my > >> comment. > >> Can you improve the fix by applying my patch? > > > >I'd be happy to make any required changes. > > > >However, is this approach superior to simply passing a reference? > > > >v1 appears to be simpler, easier to read and avoids the explanation. > > > As I explained, your fix adds extra overhead to normal path while the error path is corner case and it rarely happens. > Whatever approach is applied, we need to add explanation to understand more easily the logic and hidden trick in tipc_msg_validate(). Very well. I have made the recommended changes. The patch is currently in my build-test environment. I will post v2, when everything has been satisfied. -- Lee Jones [李琼斯]