Article View: linux.kernel.netdev
Article #25636[PATCH net v2] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
From: Juan Agustin Niccolini
Date: Wed, 02 Dec 2026 06:34
Date: Wed, 02 Dec 2026 06:34
73 lines
13572 bytes
13572 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. 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
Technical Details
Message-ID:
<20261202063404.6809-1-juanagusnicco@gmail.com>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-375590-linux-kernel-netdev=dewy.ruShow 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-375590-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
Date: Wed, 2 Dec 2026 01:34:04 -0500
Organization: Usenet Network
Message-ID: <20261202063404.6809-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1906886"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+YWI7uPxoqPJRoDhRJfzIEDCRcg= sha256:j2psaeOBx8CrVc9DApktxiEZl3mwLy2Q3qsECTp69GI=
sha1:1/mSP3mgvR+j6w2SeaGLHwEq6SY= sha256:jQgmrqa9iKd4VJg+FkiS7NNOlPJydk7gWAa6qS1peOs=
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 4C01F117578; Wed, 2 Dec 2026 09:34:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[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 bAt5f3y9D9Ga;
Wed, 2 Dec 2026 09:34:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375590-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 979B8117571; Wed, 2 Dec 2026 09:34:14 +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 3AB3628B3B; Wed, 2 Dec 2026 06:34:13 +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=1796193251;
b=SeneRMKyCeOyI1DLeFO5JGikiIvEO7Hy1AUVCWEk2SVIkIdHTFRpI2MMgAS/mhCnXk2P
Ym8AoRmjTjbHBBhxqlUDC0FwkvaHxbcZslWzmi2ghUTcCUE+KKr1K4qO254fY8AueETgV
vwju1hv9qv7fDOeaw+aArIEAg/dH+9YCQ0UCtb/hRUMG3Di082zKeg+vlgaLtJ1DoTKek
Pyyfih7rPraYV/pxBmrPMkGc2aczrL9h85SAThaZCORIt9oBkBUOYj5xYHzCVmWselSPu
jHOsz7XspCWe+esTLbFkI/YJjmYXzvTMJzJkkhOiWSv07RF1SnD3LONclDsg7pvGY7g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796193251;
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=JlQm0Dr+YXRn1KbKs+r1UyunqY89HviJtmKhg3pRFX0=;
b=g3S7EzpGQL6KgmtYjrEwC3cuLu9o+Tb2HWTsAHKtVvKS/0uMHtp6FvZ5jRqMuheVsvs2
ruyQT6ALrcj9vB1PdBI+8v6I/0e8BZa9jE/+2RBAPCu6Ybwwnfkl5yIUt7sQPCV/WBeuM
dES5lDjOK4/CnCgfmE8r1vjeBd5yGmtnAZqLdsiC1o1D58PGaCyTWFld1P2bXhIO0YRkU
pXelJeyzou8umzFadkYpGZKxAnvR8POOZ3+RO0pLAUvJQ4BHlaDuTW3gC1v5hlvvaAc6O
aGJVnFv0U5suSvNpicSlx9l1zLcEv4/YctKeH04N2Plt/AArVULUQDYJi5FRCNxBrtA==
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=R5AzM3rK;
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 EF98A606A32A;
Wed, 2 Dec 2026 06:34:10 +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=R5AzM3rK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.172
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796193250;
b=LtTRz7tXGCail1qSVNabXUPfzeEncdRDqJMOLN4eqOd5fvE9I+Dax7vhXpzP4LWXnrKW
7GkW6VGDi2u89hxCs9Y8bLeJlKWBntWndrMi6DqZobTFFKKs7yO9Wj07J4A9nChPnXqbi
en8P449LOGr2hCJeYKWPcFCb38ZDniYOlCsRSCrShgaiCqZT0JphZoYFPVKFMUp3+DL0j
oZwRnXsEv9lBjRUWZst4Xwfw2qe7/ER04KzzoYlZd+bW6SiHqUHTX5M1iFlv5Z3F5N15I
YlyaErI8xbYybnhzzY4Ty7Hxc/e+nJ+iydaYIgcYsIb6Swh0SuwH4b22+WVz0uoF9+w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796193250;
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=JlQm0Dr+YXRn1KbKs+r1UyunqY89HviJtmKhg3pRFX0=;
b=TY8vgiY+bhzwjt8l3O9EJi9i9ehRhAdIA2+WUDab9FCQwbitvJSjGSUw7VR9M2nnGJYp
nbP6AnP7lPjx0mfiXqQf/wWbQEHKFDwkEK1vAGJEVqHcpC8Y3+9C9WM+O/+FWnQhtD7Cs
5JS0/849OddEdDB+XjXu/T0Nl8Wba8ePXCmSAw/eUBUymzzh2M3tRC3nN+DNrjnj+qaTE
eNcR1LdZiSGt09vZgz/R0Og52Yr9yUDVfsLJlo7I7VEbxN5mU1q/OV0nhcYxsM1QnlW+f
UZl6MUxQQPyNHloVUAubLe4uZkIp7P3YKKMgQ3NLl3Bdwgvn1w6TEAeQZKtWqcIVbCA==
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=R5AzM3rK;
arc=none smtp.remote-ip=209.85.128.172
X-Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172])
(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 ADC3F606A31A
for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 06:34:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ADC3F606A31A
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-yw1-f172.google.com with SMTP id 00721157ae682-8b30cbfa628so93845907b3.0
for <netdev@vger.kernel.org>; Tue, 01 Dec 2026 22:34:09 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796193249; x=1796798049; 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=JlQm0Dr+YXRn1KbKs+r1UyunqY89HviJtmKhg3pRFX0=;
b=R5AzM3rK0A3yF9NG3bNtUEfBqxMrGBF8rZyQY0/WxRS6vqyneMouZkcj++9k146iuT
f1m+nbxTxJxTaXhImAbUi208cx3NFq0DLBIOvlRpCCosLVbzAlELf4v/VZlwWj2yyrXC
tSq8uYJjygQDq5MKgGdyBTuSgcPToCu1h+PsmBO+ixe7WchDn+tw7RnMYL+V45CwMQxE
GpSBM+JMDFtoBeU+8dq/JCStm4/cLMknGJvU8WRSCeyG6wX1iyn4E0Jt8pXkAiqemmdD
j3qDm/Ic37rAQEikPsZQXLlzt2/pEIJ1qwq0nY/xSHJy2Ht6symJV58rbXNjyZbKZFuh
qLLw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796193249; x=1796798049;
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=JlQm0Dr+YXRn1KbKs+r1UyunqY89HviJtmKhg3pRFX0=;
b=KQ1W/7dpHj2TSa2VJanymdGC4vZVqR81R+PgJgHXWTY75canYIN+hCxGXsYUn7eMuE
QA1WxlL/57pAHAiRf3C/UggbYMYtcpsIASEDdL+okc0AwdkGOvCfotdsP0JFXeKcp46m
L9chXgKC1oBSMWT+9MZT/lNd3PWkjMd4cir4K5u1w3F5atpEy8HWwOAY5aGr36IN4Fvh
GOajtQawwSD9SX81rLKLd89fAx1oAqZx+tZENXfICFsJcvTAOCWqA3+sMQe5PA47DcVo
vTbUtwkJU6By8J2g/qJOpkNSn3qFRvijydGVmjDsdTWYldLbmnRmaXLJ9y0ej/9IMF4B
d0Vg==
X-Gm-Message-State: APuU4Z+yp08C7b1v83GKMMnQIM4n3qRu5n7wYoFQqTkCsixfAhQoG9VM
mafaBoEXZh5HhsTaZRAJSUIOdwrIClxbghLinzepuIRQPX6v3HzaAL9z
X-Gm-Gg: AZFdTZds3Q13IWPYV6uNzjl2P35A+HaSAO6uAuf/pEza+VS/xUkykyJdn6UnUVETokn
vK5+U6cMVuw8gBxFVSRLBi3WpnnOH8hfB85jkVr2ts/s5Ve71TZfrvUM9twgv5BurOCx0fPkCgR
K2zOWUz1boyAwCTC0MGKs93SslEzV8JIXQ7IU3bqxbMp8CyCBuyKuRNBOTQG46VMCT2u/nJrwgY
sOf1+ri9gshgIopdTJfhtPfoLr8NholdmEmTsI7fQLp6pnST0AVOhlREqqh7uhOMDEyfbWxBNwU
yYNvusV89uYv24Oi/PCxnI4mKfN0uGqi3d6IQMX103UK2Bc8hEFzH+ulNykczOvh1xprZtCBOsL
010LVHntMVWXbTmqFjINXXpEdkV31y7cDIMDTaX+uuM4KnbmcU+FSCzkDQfQoKSFPfbFmFcXX2o
0nplNpQ+4wDT00IYk+hQnkPhk1qTzw3I1CWqg8dkdjTpMI0RSvrFXs5KCT4ha3ZpByimGhP5IOR
pC0eGrFnIgZdSCmy0UBOuppTCQS7VAlBnfWkQQfMnOPcwM1JW57D1XgXbuH/OIsZ51ApjNK90Se
De79qbJlfSa1xjh6gL3HdImu4SMOOp9VHtsCeDXOY7Gf+cnfVscztA==
X-Received: by 2002:a05:690c:6307:b0:8b3:ade4:a30e with SMTP id 00721157ae682-8b5203294c9mr182366237b3.2.1796193248805;
Tue, 01 Dec 2026 22:34:08 -0800 (PST)
X-Received: from VPN-158-165.vpn.usf.edu ([2607:fe50:0:f802::4046])
by smtp.gmail.com with ESMTPSA id 00721157ae682-8b52028c80dsm156468697b3.13.2026.12.01.22.34.06
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Tue, 01 Dec 2026 22:34:07 -0800 (PST)
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-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