🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24343

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

#24343
From: Juan Agustin Niccolini
Date: Mon, 30 Nov 2026 03:16
60 lines
12893 bytes
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. 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
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
---
Reproducer: github.com/AgusNicco/seg6local-oob-read/blob/main/seg6_sl_race.c

The patch 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 this 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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index 82207da08dfd..ce1d6f09e8f4 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -235,6 +235,9 @@ static struct ipv6_sr_hdr *get_and_validate_srh(struct sk_buff *skb)
 	if (!srh)
 		return NULL;
 
+	if (srh->segments_left == 0)
+		return NULL;
+
 #ifdef CONFIG_IPV6_SEG6_HMAC
 	if (!seg6_hmac_validate_skb(skb, srh))
 		return NULL;
-- 
2.53.0
Technical Details
Message-ID: <20261130031647.45247-1-juanagusnicco@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373808-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373808-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
Date: Sun, 29 Nov 2026 22:16:47 -0500
Organization: Usenet Network
Message-ID: <20261130031647.45247-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1319470"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PytC4m6z4S8BESClWKajn3MGfZc= sha256:k/zrl1QcR9aFK+zSlXEYj20hWPqbPEWiJRGEEfo1Wx0=
	sha1:m/TYU13jTixpmEemgy2nitcBbUQ= sha256:IlRT2HEiKLu8ukBMRhUpW1yWyMcyBrXXa+hpj+6VTME=
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 C90AB125FBC; Mon, 30 Nov 2026 06:17:08 +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 WoFy7pMsyKXI;
	Mon, 30 Nov 2026 06:17:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373808-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 9F29C125FB2; Mon, 30 Nov 2026 06:16:57 +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 3922A26CF1; Mon, 30 Nov 2026 03:16:56 +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=1796008616;
	b=G+NUukPYNnAbf4kkbKT/MBX/0pothYN4Mb5eF7UO4aYXTEZvxhX3lOomfuD47I7kH0oa
	 Wm1iAC8570b6ouIwdF/54ffPzyyHgUdP3UAfed3Rt045jI5V0exehKVu8MF0up42vLXhJ
	 Pcd1NVKaTr8kV3FDMWQormiNai1CTIS5omSk0McVEC9/9x8FAMQcPbHL0QDSeC8a3IMOk
	 SnzG0WDzvwtcTAyqe0LhypPaR42p9AcBl8AH7LvQEf1hw6S8AXwRE4SWAlm4O1+Z8+XMF
	 ukaKbnhiKW4qZ5uhtXlxVZi89U8Yp8TcJVbASN3QSMWfEzLhNyuEq94tixZ3dGGjUTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796008616;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=;
	b=TM2z76ZBcsGs94Dn4XueIo8hb7VU29SjGNepip3NEgkkR+j58KpB/Bs+aRrP5tBw6zQl
	 +WbhjsbltlCdhjKTBOuJzbt9uk0iQF8Z5ggKhKjCYgIl70QJSZCBBhpyl1uWbMTGsxWOU
	 f+MSnuYsT6r6tx9p6T476KyT8Cl2rK+LJ03ysgPeY4mOEIF//tt4hiTWu1qYw4K0XYGtS
	 jBJXb1+0LFSMQxCQcY73Uov/zUs0ERJKfEbKevbV1pnC2xxs6n3OVIKr30ZPMz0IbDHpd
	 TkJklsOEhQ5UxsgmSb+u4efXDMo/mmvMn83tRH3NYQ+jtGJyWb+WhDsZ8BZrPJcIp0Q==
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="s+e/YDuC";
	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 0F806606A32D;
	Mon, 30 Nov 2026 03:16:56 +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=s+e/YDuC
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.54
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796008615;
	b=taiHhdPLfSCmKjxSJ78yvnSAta2QrOVAeQWmRtwoBGgwm4QS7M1QawNYarrpktMg0uQz
	 cR8V5yqo77a3hgaU15vQSrsDb/p3VHISIh5HntY2sTgFwSWdBcOzn0wDWc/j1mBqVdFeQ
	 JV12v5yUAHzbNLs7PkFLLFEQK2Xg17Fa5Xy+y6zFpNwV+8qX9s7z3YVKOQR1Bx5gH8het
	 rNLGrc9Hd2TIoq0vdtxtde58Uuu57GS38PzRV6ETMMgRYbt1Ue+zVCiWceRZqmDdYvN3z
	 FnBCfr7wW0IWZzyq3+M3iuisYpX7YCpUXrCgc567lK+Y0lAb5ShnmcAv2jTg9gCAbVw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796008615;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=;
	b=mq9H68pNL0LWEfzdo5fCqFCCE5wX5q/sCAL3i5DqqURBqPc0NxUBP/8Qn3v2oqm1/t9U
	 X8zzZj7nlVqpc8lu9w6HgO56KicNVTtE6IWJ9uEmKp/PF8ktrlHnK2aAx8W3qLgEo7xRj
	 SCRHZ3lIM+0wYesZKaBSq7Uw+SCp2ds+wLxNFMlJEpx2TtyojvcJFdUC2fsY0m3kFGahE
	 rGqEY/uJTk9otSd0/yOwZcpfiUw/VKwuL53PKjmR0K0AxfrY2V+5hPxSAQlWFd/YOITZF
	 zH+2Zi1rQjpq46T9K1nnjWcLhCtUg1/4d+DzWhjFwn9+Oh9n0IwI4MYb3GwypL8dvng==
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="s+e/YDuC";
	arc=none smtp.remote-ip=74.125.224.54
X-Received: from mail-yx1-f54.google.com (mail-yx1-f54.google.com [74.125.224.54])
	(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 CE093606A31C
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 03:16:54 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE093606A31C
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-yx1-f54.google.com with SMTP id 956f58d0204a3-67db0791748so11170126d50.1
        for <netdev@vger.kernel.org>; Sun, 29 Nov 2026 19:16:54 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796008614; x=1796613414; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=;
        b=s+e/YDuCWapnIC2WMVibT8bqa4owPsiJJYx6sh3gOlelKjL/E+TJFLXXD27b9FYfe1
         w0D3BpuOosKS1gGM/LIpJjVK++Rt7X8mIIm2uQdRokcp8wcoUzlr6dvc+Jxn/puWoAZm
         siHFMwD1y1Xzp5ay7uw7mp9Y3rS7FEb+z2MBr310jzQFi6SKwVd1XtY+95yhU18fB9MN
         qK+a2ObjV+X63AoFcrB42WSESHQ1PsOwDgL8HymnGc6RevTH2Ez8u0Xbsa/x+HrIiQ/f
         i9KFYNWPrCe20O1iKo78Cz1QvSIZuz8VEWzDedrImzs0TG16BccvHZjFJbIyaqPVQtyc
         unpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796008614; x=1796613414;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=;
        b=0GT8/BuoYC3Olu8lcYfcN3PQMdaC4eI/fTnv6Ww/vcYP/GrPD3A/6HdN7B/2fUKDI/
         e/Q4SiKnT2fKgy4NcU7wAuelqcglQtTciiZKny3TTNhWLxEKvSf04K116ygAVQWdyYhH
         002vtAxfdBbLaoug+UFOWOX2OgTp/iBFc0QAwP5iZkdd/XHLAoQXjmQJhdnWm7V4NQ8H
         5BbVqifBATHmudkB89MgRNwlV6m6snMe2mPWR+tX3toDOgNk2w2NNmx4Y9s9YFBedpQN
         VMZ1D4H3xZmJTJeypOmkdieKHhum5uMs0WhPvmD6O27/oeDdWjp1cOpe+BEByk2/8WYp
         6YEQ==
X-Gm-Message-State: APuU4Z+fG5Lkn7JPqXNS6BE9c/O4KfjjkOM1Fat0OQZk2OtfXoMB/bdr
	RtQA2doG2pQqZVvtW4Z81DgU3VUfomJ2xlMKN8MUuvptkZbW44//Avy9
X-Gm-Gg: AZFdTZeJgcwbp7Cy7bGqB9gL5Z08lWtioAItqmti0ubv7MsrKyLFB1A5OZDu/ovAw3x
	dv49+43QOTRECfILmMTR2QUUAgQTehwKIVL55aqyBxK1mwQcve8wKDXtIrhpauaBhJ8dNCJqsYA
	yjCF3RpvCleMxRddbW0GBP9rWt9/WaHbk6++MNAhzq73rsr9e0pfPpK4IqLLGiXku6lIxt/MvgD
	Edh2tj3ZcPj2ehJKi7UchFrCIcSi5trTlZ0tGCCuQg5MKUNWwUwiqzNTyQj7VsJFNSQ/lrlgXmk
	TvKw086EYUfje6LaLd9+U7rLXVLMhqSLnA/2uoTCJJiGBVXkR9/HJWi9TOcPvbd/8XThTRGnBCi
	05fg8ctRUL2yZtAM375k0vMLjTMPxBrF+o29P+twq6p+BP2DDJfM2qFk46e+m6/IzIygRVk0dVK
	Q+Rdub0+UIb0yPdAyavuj+v6aUEoZ5b/eKAFGeTkS5E7+zekK/qZD0Da7l95aa8E00r8BYW7OIb
	z8A+gUHTGrTR1R9UVIClWwJ28ZrQ0v7P/LBsvveJHecPqEuB9T9+75UR7S5fWn9nS3HygXt/t4G
	96cPWAUuhZcZt6TH5StCyYb9j7wh7agvlOIQuToTbid0lW86qYJiNVriR124dTlfNogKUV4XnQ=
	=
X-Received: by 2002:a05:690e:43ce:b0:67c:2a1f:84ae with SMTP id 956f58d0204a3-67df4456424mr7934571d50.83.1796008613797;
        Sun, 29 Nov 2026 19:16:53 -0800 (PST)
X-Received: from VPN-156-19.vpn.usf.edu ([2607:fe50:0:f802::4046])
        by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df330fe0esm14738712d50.8.2026.11.29.19.16.50
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Sun, 29 Nov 2026 19:16:52 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
	Simon Horman <horms@kernel.org>,
	Hangbin Liu <hangbin.liu@linux.dev>,
	David Ahern <dsahern@kernel.org>,
	Julien Massonneau <julien.massonneau@6wind.com>
X-Mailer: git-send-email 2.53.0
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