🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25649

Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read

#25649
From: Hangbin Liu
Date: Wed, 02 Dec 2026 08:03
38 lines
10182 bytes
Hi Juan and Gabriel,
On Wed, Dec 02, 2026 at 01:30:54AM -0500, Juan Agustin Niccolini wrote:
> On Tue, Dec 01, 2026 at 11:43:23AM +0100, Gabriel Goller wrote:
> > On 01.12.2026 13:27, Hangbin Liu wrote:
> > > If the user can write the segments_left field, can it write to other fields?
> >
> > Yes, but from a quick glance, no other field can make advance_nextseg() read
> > past the segment list.
> 
> Right. The sender can write to any byte that is still in the fragment,
> but the other fields are only trusted after the pull: seg6_get_srh()
> pulls the whole SRH into the linear area and then calls
> seg6_validate_srh() on that copy. That checks type, hdrlen,
> first_segment and the TLVs, and that segments_left <= first_segment + 1.
> 
> The only value that passes this validation and that advance_nextseg()
> cannot handle is segments_left == 0, and that one was checked only by
> ipv6_find_hdr(), before the pull.
> 
> > > And we put the check in get_and_validate_srh, what if it changed later
> > > and before or after advance_nextseg()?
> >
> > I don't think it can be changed, because at that point we use the linearized
> > copy.
> 
> Yes. After seg6_get_srh() returns, srh points into the linear area of
> the skb, which is kernel memory that the sender has no mapping of. The
> new check and advance_nextseg() both read that copy.
> 
> > I'd add a code comment here, otherwise this will be removed again :)
> 
> Will do in v2, so that the check does not look redundant with
> IP6_FH_F_SKIP_RH. Thanks for the review.

Thanks for the explanations. I will review the v2 patch.

Hangbin
Technical Details
Message-ID: <aw_Qy2_PQiznfu1v@fedora>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375617-linux-kernel-netdev=dewy.ru
References: <20261130031647.45247-1-juanagusnicco@gmail.com> <aw5awTuHzLyY-XES@fedora> <aw6j7lz9lxN0t4Er@luna.proxmox.com> <CACQ4AchSLwD_k+uHp27kT9bsqkUchkoJhfctDHBsQM9pYQT1tQ@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375617-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix
 an out-of-bounds read
Date: Wed, 2 Dec 2026 16:03:23 +0800
Organization: Usenet Network
Message-ID: <aw_Qy2_PQiznfu1v@fedora>
References: <20261130031647.45247-1-juanagusnicco@gmail.com>
 <aw5awTuHzLyY-XES@fedora>
 <aw6j7lz9lxN0t4Er@luna.proxmox.com>
 <CACQ4AchSLwD_k+uHp27kT9bsqkUchkoJhfctDHBsQM9pYQT1tQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1919177"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:loqm/uI4aI2eB5T8T5NHbFHvHJY= sha256:Pnbw5hV6bRHrvq/A26+lPXYcGLqGX0RAmMuWjjVHpP4=
	sha1:ppDmE8TNJm+xyL1LV/nIMDwQcDs= sha256:Q5NPL88LgoC6WYtR719m+NWKitmh7lnZ44BSb4MFmj0=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D6650117596; Wed,  2 Dec 2026 11:03:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 1Zu3jeacktsb;
	Wed,  2 Dec 2026 11:03:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375617-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8DA1E117583; Wed,  2 Dec 2026 11:03:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CBDAB2C29E; Wed,  2 Dec 2026 08:03:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796198617;
	b=Dl26PfzQOYXjWrnWhsWckbdT3vfUIytxoIVTfTYrYTSseLttchdpB88tpMkNHPOQFDOT
	 0wRajgJuGDxR7REbyzl8Rg6/9uKwTXTZuB+k8SpNnifwmeJXFuO2uYSYajO4lA8UjWFq0
	 fJpmNh0cKOPxcEuPpu+vda9nYDVy36U9u0+q96scp581bbkMgw0tZLyP2jL7usGwTfoDA
	 jD+sEbrPNIwAEGcw/H8rSe/QjhNrwGz0elWTOsAkstEHP5Af510aOT4HO/72M3QFlGC3W
	 gR1EVT5+U1XrvaxRIozQNUL+xlacTu8pMM21ZDWs83nPOldzC385HiLnZtr9XDwSrvg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796198617;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=0rQPW3/Imx7ukwv47ZXjt1M4I9hwOoEOyv8Xz03SFdw=;
	b=Z2u8qlgbsyazRAv44ZYCMb1iAZZmqN6HovVI7KiJ4sLv4ITRkzpvTZNRXB8/r3gFFXvV
	 IB4mQw7HdldEtGcsufw8s7X+dRmb30ouT5IW91CwiBh1Uf19zkk8vUsaG4vlcQxbuQxZc
	 qzsoLUaX7drrlC9zo/9zr6jsE7ozNg0zW8IF8J4Eh602Mm/ef5XkdIqbjCtT3YD3Eatcl
	 /jcYIYkQpWih8hOkqqlkkyWRFK3wokl6Hdxjh98PSQ2ObaABabCRYt8QVm+UjelCU3ISd
	 BCkULBlp2yKTNWuPRx2vSAOe1u8mBHIeA1pRyHoMKxjI8SLX5+sKaIg+HURiGVc6sYw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=kHwTXQOX;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B7CF606A32A;
	Wed,  2 Dec 2026 08:03:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=kHwTXQOX
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796198616;
	b=Xlh4+qxNnTnDd2laxb8lDJYEmp0CWO6SG7qIhkKoLtPFSTkINmQz9GiW/D2db3U1s/iH
	 rLN4XjYoRfJZ6RbaY4fgwHloputlc/gtKeN1D4rvE0jDI0aZ/vb6fja8AT9WK6NPLJYA/
	 uHgWsz/J95dviN0wzsb5ho+Jk/1G63xxakFPPKejEYk/wALgZA6Ai2zRxuv2dT+I/dPhM
	 5KFVpngEkT/okIT5+xKcOdLBQQN4vwCjeVXiKrXqY9JIC2GVjUxDx/fse/NXWX2rYtruD
	 AD2LbiTI61wLlPrN1HgmdM/xcR/ef5x7a1dfpw/ykFiRRosGVG2tHV7TdH03xeZZjsA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796198616;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=0rQPW3/Imx7ukwv47ZXjt1M4I9hwOoEOyv8Xz03SFdw=;
	b=OJzFnyAQ/Z/MLYSYnQLHJNRB6urWb/LWhwpDU92pLxyX6W5MEsJJAOy0NyqYLCpYqn75
	 sdJw7Yh5lltFWkNg8lmmcnFKIYhdkshfoFIo/Szl1wcXW7j3hMKIbdBRGOOH5N4tbFVMr
	 R60xLLXBTGr1vmo6TmlQvng+SHYms85GX/zun9MoHXBYMyyY9mAsNjHTqqEibuncLS+qT
	 rd/rkvmm4qM4ru5MdWSxtIJX8hxqlNVaDE8z3mv91J1qVkMyYjhFtZpSnVGtju1Ldu4sI
	 rH/Z+3ObQ9JGOU/gDUCYvSNk/3X3dtCW+h/hE9w4nDUqbZYz6LM1WgjkvqfhGONDTUQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=kHwTXQOX;
	arc=none smtp.remote-ip=95.215.58.170
X-Received: from mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170])
	(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 5B930606A31A
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 08:03:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5B930606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=w5UDwtL+LnsdWLEayK9kc/6U7Um6Z3jEVyEd7jkTfxg=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796198613; v=1; x=1796803413;
 b=kHwTXQOXLkOyYIKk7q6Xz4FdQMVlsS5mj7PFJ3jSbP4OOoQOR9Z3EHFa0kAgR3Ux8wv5BOFq
 Smdy3Ou7Byp3HhYUP4v/zgpnCqHmDD9Is1h51d0WTetbNYXodo6YBcseaAUAfhcraiLcTnw2wDw
 NJB7rakh2KI4bFZONBNsIDXo=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id 853c0bdd45a4402e;
	Wed, 02 Dec 2026 08:03:32 +0000
X-Mizu-Trace-ID: 853c0bdd45a4402e
X-Migadu-Flow: FLOW_OUT
X-Cc: Gabriel Goller <g.goller@proxmox.com>,
	Andrea Mayer <andrea.mayer@uniroma2.it>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>, netdev@vger.kernel.org,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	Julien Massonneau <julien.massonneau@6wind.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <CACQ4AchSLwD_k+uHp27kT9bsqkUchkoJhfctDHBsQM9pYQT1tQ@mail.gmail.com>