🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25916

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

#25916
From: Justin Iurman
Date: Wed, 02 Dec 2026 17:50
76 lines
14469 bytes
On 12/2/26 07:34, Juan Agustin Niccolini 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>
> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
> ---
> 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;

Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Technical Details
Message-ID: <0315fe49-6ba9-4d85-8719-5ae49b982e3b@gmail.com>
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-375980-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-375980-linux-kernel-netdev=dewy.ru
From: justin.iurman@gmail.com (Justin Iurman)
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: Wed, 2 Dec 2026 18:50:47 +0100
Organization: Usenet Network
Message-ID: <0315fe49-6ba9-4d85-8719-5ae49b982e3b@gmail.com>
References: <20261202063404.6809-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2024938"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jpGePmS6V50ctMFj579nnYW5oSM= sha256:DcRv+iFdCJJJW9bJGKMbSmopK77GBt/pBnVcD51s9qQ=
	sha1:RMFxMys9hse+4Dk8as9Xt/Ilfik= sha256:igB8a/btmMAKZITqO/33bdEGUEzLC4mqJz6G9Hh4c98=
Content-Language: en-US
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 5016E1176E2; Wed,  2 Dec 2026 20:51:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, 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] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
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 FHny9MGkxrw1;
	Wed,  2 Dec 2026 20:51:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375980-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1D9E31176C3; Wed,  2 Dec 2026 20:50:54 +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 7102229874; Wed,  2 Dec 2026 17:50:51 +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=1796233851;
	b=1lxtpB0GpmOC9DR9EINDNRHFJvSabxUbDPGCY3H1QwZ0Fmf889KzgnI1BX/qzdhqrEyM
	 VQu/o1YqCrc/PbgbSFrWIaYi8ZEX3t0h/hOZq5DxcSxuDaJWfNbxVXIUJcHWSOSIr04dn
	 BnvTW5YJVobeHii3nDbO0qvf6qDRcPvVzHAQ6eHuD1BoVjKV1vyEzxRkh675lFoFQaZXb
	 sX+Nb1GKjtn25PuCqr0qWnBSF+pmaPtxEKB3Lp9zrt0TJFlXa5j6qJwHtHLHa5kS/7GKR
	 y+efj+nDmRaCMeCmg8io8IE0Tv+2MhZsHlt3wGvgvoFTK7ynY+jizQb1eHgdiztx/0Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796233851;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=;
	b=o1xb9SwZC+VeW0KUrWlt0MjhAiHaIqMxTw7uvkVJYsy2wRhAgKC/ACyALRNs++SU0f0k
	 u24gd0FD9GOm01fgc4sd3NSKk46V+9Uvv1EKl1k90FnXWkdiKz9Om/8eAjcyEKSC7/LIX
	 T7erpE+qUoooUSOVYt9IJGePGaGnGrwiaQ3aJ18nWXNqLg05EDPoRjqikeT5mmvVTBLg6
	 CKsxZqvdhE02SUVjjKQGcSo42BUT7wOPSVEzu03MXilzpV9+yaVBAuzHkPX0Ay+nCcW1u
	 IthLwuK+Lxk6BuyggxCJJHMnkgDtrQrbkBMcXNczxxvN6cT+6vVqlVfhFTP7+QZ9ZxA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hPa9dOpB;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 49140606A333;
	Wed,  2 Dec 2026 17:50:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hPa9dOpB
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796233850;
	b=yDWFNGEFo2eddvJ4djB/7dW4yaahBDjlU0dI1M6j5QnjJt9mGZ52MDyPvL/ScfKRhChh
	 K4UqUbRs/ZtlhrJyXxnIK5ea+p3xUpmslc0Lx4LYGT9sYDutRuvLnXsfJlGJoGhv3pq9t
	 bgpOw/ZFAKn+xEUCI9xKp4VzfnowrpG8zpWF6ic1rd75hmWbyZgtP0Q5klbKUN+WJOimE
	 EmRYIv/4Bv2AwZyegNVt6HLhuQm9eOp0f2nghCmBY6990v4ZjNny9I/OBm1VKt32+kvJf
	 GP6izez2O5+rUGYKftjJMfUkQVty68aQrjBlD8Mo9tj5egQrbycGYtJ0KR+8x/XDKCA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796233850;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
	 MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=;
	b=fnolWLL28gndKW2/c2dxCE0HM5/AB7EB6AJCeEIlGORILHPuUg9SNN0dk/P/lKucNMr4
	 jSY+VbBLU64ss5MjmNv6DzUAA/wLEFHSd3aNORs3gLFqWH+sojbzoORHJwdjM92gZXpQX
	 /xwRO65RMIn7/6lFHjCEZ6YDMSR1CebdMYvtUYKcsdod8nvfnoLx92SsHuSYGRQdiiyWG
	 +u1N9DGiAxADbv+xiwKzjJEwvqWsMXBnvOoNfwW46zy8hMjtNHmwT/jSQYPgGc+7fme/M
	 YUoiMGb8FssBrQt3gc7LVaRcjBAAUhdab8qYPLGNhYTMDoW17q7L7twjAtvUFkHgKfA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hPa9dOpB;
	arc=none smtp.remote-ip=209.85.218.51
X-Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51])
	(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 0478D606A322
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 17:50:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0478D606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-c4395d31228so2346823666b.1
        for <netdev@vger.kernel.org>; Wed, 02 Dec 2026 09:50:49 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796233848; x=1796838648; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=;
        b=hPa9dOpBcOs+wybj5dSvVCX3wmIEvJTB6ey63XA1MlPJinYVPLZ//AvXZovTmCMtKe
         gDXEuJYxaPsRnqoPdA9aD6/gmAXhnlzhmOEV+atCndYbCsHKAAVNPBY+T/0yckc1h94B
         c4Ij07ywvXwa35m8c6k07DYxTiUkBUUGoCNc4CfmXp+DvsBo8pmGeSrKrvvvSNnJSBF6
         xJNp0OAcsR+o1Nc3n4NuEk0fJd8u5ShmlN6/ixDN/TwkYBZGV7pfLxaEelh6Ss4470hK
         eTqO9axQtu9JwYXEFfGEbAYzi2L3DQBp+amHC+pMa8Vb6xI751ccJPWaOfPdcjkexTAU
         R9iA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796233848; x=1796838648;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=;
        b=qXdzB+MVGM0DNmoeVcSm28vSMT9uuX4eshJPFDLT22zcPkFSHcSVfTq1Y5XFKfO7F+
         pVnlX9eUi6czVQqUJgdvzFICG4evshfgohizdGUSpWbY2uDM1dOqhmwufUxApHORztey
         QpMzHv+VubU8ejwDjGYEAHXuw7X9FlVvrBDVLsx4JcmIzss+7ExOLrJnaSf6SeDoYWNs
         I9X7XkbdyZaePlb4PO5nFQVRnGfUl6ny7HfFxfgQP/qzVuoqSXlgy1AJ9eNlOA7z6cPG
         Zh6HjCWGTLAKe3c62o97cb+2fq/YKKCHmWnEux5Lqa+3raH8F8JnmCkPGko8YYag2DNS
         a0xQ==
X-Gm-Message-State: APuU4Z/iiybxZ2IKoXAjKDrF1x9Op6DuSmfCVQk6Kv7cMgRYgxnD6GTj
	v4wxcaabcBXEk4WpjEBaOQPM73UE8ew3Bz59/qHXZsMW/1y9BaEkKFO6
X-Gm-Gg: AZFdTZfSE1+leKMW6DRJ75EZxiTaVPVX9OsNfrh9gy45nVwrIAoD3TGndMdw854Osz2
	rEO6w+J/RPrf9AHfmO7wRShelPN8dPQ2nZclN4DkkQWuo1i8ihqNSBIW735DJ6s2tuJkByrH2fN
	FiiUQNXSSXlxKAu2eVOLTErIt6dQjbR6z9UivZd7KLlwgwMH/8tmF9m/GUqLTH90MJhPDZkEU9S
	J4gXznoXCpkSKySBs87LP5IvC6Ljf4Pffv4ICUKrJnNqBjMxob3/6dxJOXZE9NU188h0XxqCEOS
	VlrlbEP03iggvx/yHDQNjN0+XUZOCRxyeoOcdc5H2A22VIGOOzKH7AmOp+T9q7X8thhInRK74OY
	DjGpPOXj7jeP7qLV3hhl7XLXPGV+mDnB7Hyf2JzIzw3f2YJyiAyOgSpx6Do0nxqXNaF9KKcKI1o
	5XccypqKgMKyf2YfvY7aoSH1SytDv4NilbHAl9xE2RmznvIKo9gftBAZx4jy7PL8HYrOAB60VBU
	XcOUn9unibsnB83SCkjHF/Ranmrs/MbK5DLjkjtqzy3y9loByW01aajtQni0tucMD7rAyk0aJh6
	MO4ihayT9WWKNV2hjFeuUrkeQSarUITQ9CX+EPKU7u04VsCAIlr+sQbNdPa72qSjveE14ScfocY
	TOJ0=
X-Received: by 2002:a17:907:d02:b0:c51:558c:7654 with SMTP id a640c23a62f3a-c51558cefc9mr3450301666b.7.1796233848127;
        Wed, 02 Dec 2026 09:50:48 -0800 (PST)
X-Received: from ?IPV6:2a02:a03f:a75e:9a00:3ec:6081:8381:79fc? ([2a02:a03f:a75e:9a00:3ec:6081:8381:79fc])
        by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513aea3537sm1330196866b.36.2026.12.02.09.50.47
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 02 Dec 2026 09:50:47 -0800 (PST)
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-User-Agent: Mozilla Thunderbird
X-Cc: 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>
X-In-Reply-To: <20261202063404.6809-1-juanagusnicco@gmail.com>