Article View: linux.kernel.netdev
Article #25656Re: [PATCH net v2] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
From: Hangbin Liu
Date: Wed, 02 Dec 2026 08:17
Date: Wed, 02 Dec 2026 08:17
77 lines
11740 bytes
11740 bytes
On Wed, Dec 02, 2026 at 01:34:04AM -0500, 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>
> ---
> 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
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<aw_UDWCHaUBJJuK_@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-375625-linux-kernel-netdev=dewy.ruReferences:
<20261202063404.6809-1-juanagusnicco@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-375625-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) 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 16:17:17 +0800 Organization: Usenet Network Message-ID: <aw_UDWCHaUBJJuK_@fedora> References: <20261202063404.6809-1-juanagusnicco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1921335"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:fuDAs5xikXW+Qlh+mCRdWqrGFLI= sha256:KFlP3yBwmLYsYl2Y7Ow4tJSi+MS2/MsrUqL+BNdTG3U= sha1:e1RtEw9C5ljINzVls5lVIrW1eNE= sha256:bj1TcyBUS7u0g/RJcUVpke9gROASnsCnEEIbbJndqOw= 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 B7F0F11759E; Wed, 2 Dec 2026 11:17:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] 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 xXNhWws_lOZI; Wed, 2 Dec 2026 11:17: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-375625-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 EBC8F11759B; Wed, 2 Dec 2026 11:17: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 BE23D2E3D4; Wed, 2 Dec 2026 08:17:36 +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=1796199456; b=5X6inzkV+UWTMlFbBYwlnRTqtc5sDWdRy1LEU8XODQMEVzQIqnFXBrBe4wf7h41hVHlY OQeS0Uo9U5t7hfGUeBhUZ2XwOV6L7dnm3UOWeq98Syntt5/Nw4OJRG7A3xZpLT0xihldN pBU9Ie5txdqDvl5+Ej8J8Hd6r34SO5tNPualLtV5vd/YjTzssUZh23D2p4K7lNO+Bv+tr BX3w3vXfMEf1rX3sl+1BFQJuPQ4vgBD1lVIgBuQfEfsKf6gPJAKdcRAsU6ALzdZSG1rMp qqEIZwBYAxO/9p61yV6WRm+6SiKhWcc1nFVUfdg1ytOCkBEnWmDUVH+GJggCs9XQG0Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199456; 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=oirCu1NdcHTzAUn4q3MBXIYpPqwuiBLtFjVid722PpQ=; b=xBB7sx9wdaIMf3XVzXasfYCSwKF4jTpiXP4xjM+krubJD8Kl5mRcu0WeoRdEkSe3IFPU QUBF9kHW9ahz8UHvykkzDKNvpQMqiT43XOLEWixgLd/h3GKRr7EmcKjxFipO/l7g5hNlN j9tAv6apzj2aLeODoJLeII/3cLjGOWVqh0HKUMF4RXuanca3lPDEXSj8/Whb+lgiOYP1w /pyJV+ezyMctDcyGTzNbA3R7gwFHJbrij/aDR6Z+HhLcOZ5j1EjgCOnHEMOy7moHRJcy4 3JaFzjv189LdilSEFr+9DqHm8SdrgPKg7pb5iSZfxUE4abqkTQLiJNc/z+AfePqTX+w== 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=anLC5xIm; 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 94C94606A32A; Wed, 2 Dec 2026 08:17:36 +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=anLC5xIm X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.70 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796199455; b=ksAfKmUnHSIg/kUCItWWEiMyMbSqJ+6qyN1zZzboyNdwwht3XpPY3QIcwqMFHLmW85Vk 7MofhObrqGNS9wluqek0Bh0ro+rNPAt9l4CXnzwvUodnQH5tzgcx4xdLmnKIsaMQmUsaH BcvC7lvAs3vqkTScHESGUOnkMj0ZzR+sArC37TlkEZulBks5RjqevcyWI/DQo8H+d0mJs oQswiw+wT3ftJNbRy5CFjK4BmpPQ1BXSdXazDmH73zld3C0vX4J/ziv3E1z3mu6F3kNp+ WKHUkrnfpCy7UhtBXcy5Srb7zZEjZeZ6zgl4aAqKD5zgfTQ3tUN8tXW6KuaKS/XdxxQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199455; 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=oirCu1NdcHTzAUn4q3MBXIYpPqwuiBLtFjVid722PpQ=; b=LKZE+fgbNA+EMTJtvFZcJsJ6GXYBkKAiVEcM116tam5PTr4l11hfE2u6I4KsgIgZAHlu UOre5j+thgVpo0Vi1/7ke2jwJOsVNffwlP+fbYpTTsEggHPJh5vV9iu9F+6XrqDxGsLGZ Ggu9PAXXwW/FdNovNxki75pMQRMkaetRPGInxEscm0LXcYqUKCD4YCAXm6gWZe3iEL6qV SSH8PWlG/CiQP4VMuYLA7sB2HTI8tqlanyMX0xuepVjCoVENDVUMfvZ4VaN8hjuBo7fGv rmTLPS6W/lJZc0cBmHb0LiXaqWfhA8mBLJsMbTzIGbhtDnBSAXACbUY2iM87x3yqeNg== 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=anLC5xIm; arc=none smtp.remote-ip=91.218.175.70 X-Received: from mta0.migadu.com (out-70.mta0.migadu.com [91.218.175.70]) (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 95D5F606A31A for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 08:17:34 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95D5F606A31A 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=1KRnSJyT0x7gApYIU9Q8huiXkoL6dHpvr6g4D/KjuRc=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796199452; v=1; x=1796804252; b=anLC5xImbC1AaD/2Vzr8zMYAq5de6GfhTmxnKe1bRgX0unz0JRDuMPPt9oB8jc2AGjPqndfk 9iHWQBNWVn22pafySvNpaUS/f8em1T7mgsDW5Kbnqi23VwZolaqPC1+1yQo7QgVyATR8NBVwmbs Q49pgnF5nRUB3IhGClel9jM4= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta11.migadu.com with ESMTPS id 069d6ac2e2addb6a; Wed, 02 Dec 2026 08:17:32 +0000 X-Mizu-Trace-ID: 069d6ac2e2addb6a X-Migadu-Flow: FLOW_OUT X-Cc: 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>, Gabriel Goller <g.goller@proxmox.com>, 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: <20261202063404.6809-1-juanagusnicco@gmail.com>