🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26067

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

#26067
From: Andrea Mayer
Date: Thu, 03 Dec 2026 00:41
81 lines
13505 bytes
On Wed, 2 Dec 2026 01:34:04 -0500
Juan Agustin Niccolini <juanagusnicco@gmail.com> wrote:

> get_and_validate_srh() relies on ipv6_find_hdr() and IP6_FH_F_SKIP_RH
> to ignore a routing header whose segments_left is 0. ipv6_find_hdr()
> reads the field where the packet data is, which can be a page
> fragment. seg6_get_srh() then pulls the header into the linear area,
> and nothing checks the field in that copy.
>
> A sender that can still write to the fragment, as with an AF_PACKET TX
> ring, can change the field from 1 to 0 between the two reads.
> advance_nextseg() then decrements it to 255 and copies
> srh->segments[255] into the IPv6 destination address, an out-of-bounds
> read 4088 bytes past the start of the SRH:
>
>   BUG: KASAN: slab-out-of-bounds in advance_nextseg+0x2a7/0x2b0
>   Read of size 16 at addr ff110000128e9030 by task seg6_sl_race/289
>
> An unprivileged user can trigger this from a user and network
> namespace, with a seg6local End route and a TX ring on loopback. The
> 16 bytes are returned in the ICMPv6 error sent for the new destination
> address: a kernel heap memory disclosure.
>
> get_and_validate_srh() used to check the pulled header. Commit
> fbbc5bc2ab8c ("seg6: ignore routing header with segments left equal to
> 0") replaced that check with the lookup flag.
>
> Fix this by checking segments_left in the pulled header again. The
> other SRH fields are already validated there, by seg6_validate_srh().
> A header that the lookup skips is still skipped, so a packet with a
> second SRH is handled as before.
>
> Fixes: fbbc5bc2ab8c ("seg6: ignore routing header with segments left equal to 0")
> Cc: stable@vger.kernel.org
> Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
> Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
> ---
> v2:
> - add a comment above the check (Gabriel Goller)
> - say that the other SRH fields are validated in the pulled header
>   (question from Hangbin Liu)
> - add Gabriel's Reviewed-by tag
> v1: https://lore.kernel.org/netdev/20261130031647.45247-1-juanagusnicco@gmail.com/
>
> Reproducer: github.com/AgusNicco/seg6local-oob-read/blob/main/seg6_sl_race.c
>
> The code is unchanged since v1, which was tested on mainline
> f4585067150b (same seg6_local.c as net) with KASAN: the reproducer gets
> the report above on 100 of 100 runs as an unprivileged user, and on
> none of 20 with the patch, with about 300,000 frames sent in each of
> those runs. The repository above also has the full KASAN report.
>
>  net/ipv6/seg6_local.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 82207da08dfd..27157a4456b5 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -235,6 +235,13 @@ static struct ipv6_sr_hdr *get_and_validate_srh(struct sk_buff *skb)
>  	if (!srh)
>  		return NULL;
>
> +	/* IP6_FH_F_SKIP_RH makes ipv6_find_hdr() check segments_left in place,
> +	 * possibly in a page fragment that the sender can still write to.
> +	 * Check it again now that the SRH is in the linear area.
> +	 */
> +	if (srh->segments_left == 0)
> +		return NULL;
> +
>  #ifdef CONFIG_IPV6_SEG6_HMAC
>  	if (!seg6_hmac_validate_skb(skb, srh))
>  		return NULL;
> --
> 2.53.0

Thanks,
Andrea

Reviewed-by: Andrea Mayer <andrea.mayer@uniroma2.it>
Technical Details
Message-ID: <20261203014126.17042fd20e0f45d66c7626da@uniroma2.it>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376168-linux-kernel-netdev=dewy.ru
References: <20261202063404.6809-1-juanagusnicco@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376168-linux-kernel-netdev=dewy.ru
From: andrea.mayer@uniroma2.it (Andrea Mayer)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] seg6: check segments_left in the pulled SRH to
 fix an out-of-bounds read
Date: Thu, 3 Dec 2026 01:41:26 +0100
Organization: Usenet Network
Message-ID: <20261203014126.17042fd20e0f45d66c7626da@uniroma2.it>
References: <20261202063404.6809-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2098185"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qVjW8xkIa5HNJnKWDdDkHLlQIvU= sha256:lK0Eink28mAbfAWxlu1cECrxVONERT42hbEW/ofJm5A=
	sha1:ZAIKOalr3wG/XOdCujZdIy8jYTk= sha256:06kBbUhY68pP7mP5fThZLGd2GTyF4FEd7hBlYoNXSfM=
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 4A79A1177C2; Thu,  3 Dec 2026 03:42:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -4.875
X-Spam-Status: No, score=-4.875 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	NICE_REPLY_A=-1.724, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=neutral
	reason="invalid (unsupported algorithm ed25519-sha256)"
	header.d=uniroma2.it header.b=zWvmmtkN; dkim=pass (2048-bit key)
	header.d=uniroma2.it header.b=u0Ug2KgY
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 lLYutswD6u5v;
	Thu,  3 Dec 2026 03:42:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376168-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniroma2.it
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 15E6D1177BE; Thu,  3 Dec 2026 03:42:13 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id DE0BC27C6E; Thu,  3 Dec 2026 00:42:11 +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=1796258529;
	b=Bz6RsSW07HpnwrjzS7fVFJ2a4HFjZGvOksklPY6/EVXGUS+7wa2i/Jf72QXfkzbdCzag
	 9PnVMg8OjCJunF2tDWp10KJQrpepFvpJ4ptjA2SSvA34vJG9oC2e3AyDnmE17UtFhaEk5
	 neXCBTUS8sVbmaEvVwciiffNZI53H4MXLqVjfoiC5oQ03nsW3ER2reCCvfFiNWPov3cVK
	 v6h1oVaz/T6SRsAXicgEc5SlgPpuTla4R0PvEbL1ZHRhFFkGnSI/FaPWKHwnxEi7w4K0S
	 YeJ2A6rnhLs7W6LGtDzOFT0JAOfeHb9CwQJmAPOqwJgXkhNFY479RptpeP9QPn5f51g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796258529;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
	 DKIM-Signature:Date:From:To:Cc:Subject:Message-Id:In-Reply-To:
	 References:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:Mime-Version:
	 Content-Type:Content-Transfer-Encoding:X-Virus-Scanned:
	 X-Virus-Status;
	bh=/qmCAjiveNM0xR6VPCP4+xucN22RkJ+znf32Ix2ot2s=;
	b=tgPr6PxY2DRCmvKv0hUacD/SI/UuqNiz7QZrL/NLVvLn+cpwuCYdaI7Bn7y2a51k2XDL
	 iA2ECviR+mdeD4zwuZkSznwrAtgNONgEQypa816FO6daL+m8en4cfuD3NDz80vRQmU4lI
	 S5PDCrRcmFkOM2jGKAEWDQWmNkBStnJb9jAD0I62KEus6NyNMJ3BSikqPh0jD7iEj/zBE
	 CcGXgL88C4V2S5bP21AzYOLud8NXhOFWfE/T/mlBdKrxdIrQwghMiDegyHsTTjE186etZ
	 bsPwwBbuzfnr7jvBAbt4pMYdo/1oxEGp/67vaIkELUPNVxHJ5UPf3J2J0NzvTu0ILQg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=zWvmmtkN;
	dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=u0Ug2KgY;
	dmarc=pass header.from=uniroma2.it;
	spf=pass smtp.mailfrom=uniroma2.it;
	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 7B420606A333;
	Thu,  3 Dec 2026 00:42:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=zWvmmtkN;
	dkim=pass (2048-bit key) header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=u0Ug2KgY
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=160.80.4.32
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796258528;
	b=tuw3zc1i3O4Dez9G1yBfFm6jFEFxw89ZAFCH0Tv5Q9rQzYuVmCg2ei1SI+zv0G/OmPuN
	 KsYHOOwJnNcOwLFy5+o3u6FZLgwaCpjZSgoUQz0ajmI4h0DnCUnZUJBSJ8MZOJuX8fzwI
	 Tc5gUygXKQkJhtn4ODaiejxL6xCpEtdORqmfiZ4yEpiVIRKXWgCX6xdAkf7IPkuXJbzzm
	 w30wUZzcUKADGC0VvkhAFYFuLJxM/c2ttMOipk+GgqLNuz9TZNlsaUrGqm18UnvoojW6p
	 9Eef+O3pdR3EeqkdCTTV7IjqNsS2HJ4OfaJIpYFtugCkKofbTOOuoJoLeME8wLj2p3Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796258528;
	h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:Date:
	 From:To:Cc:Subject:Message-Id:In-Reply-To:References:X-Mailer:
	 Mime-Version:Content-Type:Content-Transfer-Encoding:X-Virus-Scanned:
	 X-Virus-Status;
	bh=/qmCAjiveNM0xR6VPCP4+xucN22RkJ+znf32Ix2ot2s=;
	b=IyM43CPm8qUCIXBB471aDYp9QDRtCJFd7/6U+OWMr6TGlRhi0st3HnRk6LY5YCtCzQ2a
	 kyN4dWpDB48BAk7mTSmxDqzK24PeOioOlqp16r40Jc8FvXuajlZ2o8JgKYr8s4OSyru2a
	 iLd0UDpDQrc8EKqA5JIbmRyrLoPMAVFHmOj67AeQYKeiFqykqfX8VC3JsTokeq7HjKWcn
	 X6fHfWd+f+1OGsIwoLEF19BdowQA+AbFp3Tic47ME+5xsuUNwADbNI2cIzndRzVxnxnl5
	 vd+JJ/nnIvz+h89hoqxAJb9iyIs5oeb+dwllAevKvAeqlRRKkfc+H8Rc/Drqd5L5xjQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=uniroma2.it;
	spf=pass smtp.mailfrom=uniroma2.it;
	dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=zWvmmtkN;
	dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=u0Ug2KgY;
	arc=none smtp.remote-ip=160.80.4.32
X-Received: from smtp.uniroma2.it (smtp.uniroma2.it [160.80.4.32])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id C56C5606A322
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 00:42:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C56C5606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniroma2.it
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniroma2.it
X-Received: from smtpauth-2019-1.uniroma2.it (smtpauth-2019-1.uniroma2.it [160.80.5.46])
	by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 6B30fVNM031085;
	Thu, 3 Dec 2026 01:41:36 +0100
X-Received: from lubuntu-18.04 (unknown [160.80.103.126])
	by smtpauth-2019-1.uniroma2.it (Postfix) with ESMTPSA id 92E251228CF;
	Thu,  3 Dec 2026 01:41:26 +0100 (CET)
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=uniroma2.it;
	s=ed201904; t=1796258487; h=from:from:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=/qmCAjiveNM0xR6VPCP4+xucN22RkJ+znf32Ix2ot2s=;
	b=zWvmmtkNtv+U/C62nnUH6Jq91xLO2iyOyiH3c6JpFTpmFtUQy4h0qnFiuCjcKXFNx2dI7s
	nhJ2V9LSgNg5W1CQ==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniroma2.it; s=rsa201904;
	t=1796258487; h=from:from:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=/qmCAjiveNM0xR6VPCP4+xucN22RkJ+znf32Ix2ot2s=;
	b=u0Ug2KgYbivnMyIzH9q1kw1uLOtoabf25F/imNzKKIq2CU4U3du6u3acO3GPBMQBHZ/oMV
	U1IzyOHoV4LaTA9SVEj0hWEvqMXdnZBAGkVoVpjnb0TrYhswXmeyouXRRmCzmXp5nXUfBN
	1CusCrSnyE0eXTY6FJ8PxemoxwchmpuRfZXaNM8W5dbe4yArNfiy51xP1NNgbzPk71rcQc
	uP+IZithsL3w/aze34CjgH9OODTfI7E8V6lOvFQ/ntk8ryBhW+bdueDHzFHEq3P2cUaZgj
	qy1X3v4P0Yje80U4ETzaBtmXkhRTa5QCRJ6J9vq3R0Q3uL7JkbKesnwytUk0sA==
X-Cc: "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>, Hangbin Liu
 <hangbin.liu@linux.dev>,
        Gabriel Goller <g.goller@proxmox.com>,
        David Ahern
 <dsahern@kernel.org>,
        Julien Massonneau <julien.massonneau@6wind.com>,
        Stefano Salsano <stefano.salsano@uniroma2.it>,
        Andrea Mayer
 <andrea.mayer@uniroma2.it>
X-In-Reply-To: <20261202063404.6809-1-juanagusnicco@gmail.com>
X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
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-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015
X-Virus-Status: Clean