Article View: linux.kernel.netdev
Article #24974Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read
From: Hangbin Liu
Date: Tue, 01 Dec 2026 05:27
Date: Tue, 01 Dec 2026 05:27
71 lines
11199 bytes
11199 bytes
Hi Juan,
On Sun, Nov 29, 2026 at 10:16:47PM -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:
If the user can write the segments_left field, can it write to other fields?
And we put the check in get_and_validate_srh, what if it changed later
and before or after advance_nextseg()?
Thanks
Hangbin
>
> 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:
<aw5awTuHzLyY-XES@fedora>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374707-linux-kernel-netdev=dewy.ruReferences:
<20261130031647.45247-1-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374707-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read Date: Tue, 1 Dec 2026 13:27:29 +0800 Organization: Usenet Network Message-ID: <aw5awTuHzLyY-XES@fedora> References: <20261130031647.45247-1-juanagusnicco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1624553"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:oEp7SGiECfQ3RXpXtJzKb9m8pi4= sha256:mees2F1Pwt0v2cjmswI03/L/5nvsB9M8PRELwRytFEE= sha1:cwVZABgD8FN48zLFF61GOTAvJTk= sha256:P2mnn7rghGFEz2uoOsQv6+5bOdWoYDzxf2W9ohVFHOA= 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 B5467117233; Tue, 1 Dec 2026 08:28:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 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, URIBL_BLOCKED=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 1U3c6l3BBZFV; Tue, 1 Dec 2026 08:27:59 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374707-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 73477117231; Tue, 1 Dec 2026 08:27:50 +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 C001D280BF; Tue, 1 Dec 2026 05:27:47 +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=1796102867; b=J3AcSbKpaqRKf8vLnKFpji4KjSAwsQf7iHfnUbDne85+KamJIz1FWa9cPHybuvLFS8nF YLGRO/SqgTPFae8LkvGaDq3NO+rkzQYFOf2S4GL4uaqvodyKeLtDw2M9Jb+lYQSVOwAV2 6NHkfSxSnu1uCmY3W6/Dou0Y3RELpQk2WIX+nl7A83AdoEOFALqNWidTR+j3/DLcB2+w8 jIExBdPrnPKd01TJRCZGxIso6P3QRYiCRGDq5U6G1BEKjCKWU0xHR4MN0WqRJGfGFgdrZ L4heYqUOLuiM6Lvo/8TTK848hRaaMx4RzAV5XMJBYyCAvT8qZrPnl0L7Ro8qxTNKghQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796102867; 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=kt8JP2MwBVq6MvcVtYkrKrMY+yMisaswanPKV/OYsPc=; b=KwNC9PQkmJINWHEy/6kLHT6F36/ZENFVlBcc12iKg2LFihNp6Qi9K+TDi7q09hix7JVn CjHMGrklETQ7UcIsI1vPwrc8qRsVVJnZu12kyXaVf0AwfOWsL0NWZTH4Ux03TwuYq6oFb bMlA2i2zlxcuwiYSf3FU9Qs2UJzJch9ALtq7cfIoOntGcnrtKArnRb4MPF8ZDwpYrVCA4 yvs+47RgSBvFAGdMJrN9KeMwXdzk2DEbwGk5YfmjcrZPjxu0jtZIwu7dPylcBwKK6rlhg h4C8HEdaq3pbcrVqyBG32Vl/rl9hBpYuINcOzNR55YGmIsyYBmAgzQO/uhY0rhIWWew== 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=oZ5Keb6d; 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 9705B606A32C; Tue, 1 Dec 2026 05:27:47 +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=oZ5Keb6d X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.141 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796102866; b=hPhpyLiAvHFnfHWGvK+qxnkvgJCejJ4R8YrXLdu5+Xt9rLn3p2xkzaKgAlckmByzaFuZ uzVdnhT8GEVgTHms9wrN2MPy/HlAHz7KwHN1Aglb26g9fjyYp7pPv7lFCrgSV03o0uk7q 0G1HFNDLLPgnvuHZdbbEoL4AbObfl3f0IqojN9E5ClcKlx5gqe9zOpYzw/DU5MC2US0E2 oGvczGUDjUCsYSt/H+8VH0XF3J8xSFJIsKXAGHlpUbEzQ/fnv4FqUTltAOICxUrmoYZVF Wywng7AgcsjUwjiNajIwESrj2uUy2Nwodp9dAqZ8Hk4kwWQKs10tWELntHGCH4of99g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796102866; 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=kt8JP2MwBVq6MvcVtYkrKrMY+yMisaswanPKV/OYsPc=; b=Ytpw5BUsS3S9Lc0Gi4LBbsMTc0jtZzYti6R2ciU/ADDhZqqZBPBc2I2hcbMpn5RY1Tsf imBndvc9ZoqB0uRgVHFKd8eF2BbETTRxfhWEri1H02B5jDmIY9M+FU5DzYENqUASBUXZC Muv6AsuwWwrMCeMg2YW+j+H93E0sHlTcTJ0wUh6oslEQ/rZ4Q4BQ7gNnWtuj20zKgIw2w lVM3kTEVs6oYmE2VhmEO1jbISZO8GJLQsx1lKusu77lzIsxuVyZD7f9PQSSfGh1Ml7bSa PWWIIGGmIvD4sMevHxSQbJn5zG4FFWOUn1s+qdZ9p4K+Np/8uOUwNuDqDab/5uhFAQg== 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=oZ5Keb6d; arc=none smtp.remote-ip=91.218.175.141 X-Received: from mta0.migadu.com (out-141.mta0.migadu.com [91.218.175.141]) (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 06358606A320 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 05:27:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06358606A320 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=hYClrZhiv6bhLBaADGISdJoeUVIw/zcO0Ffng58XE2I=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796102864; v=1; x=1796707664; b=oZ5Keb6dXQ0rXBznn1fcyURqBAKwL55fXqyJlW1r4/JQhTEai7+/1FcqLdkdqXgEpGUpxa2g A2HGLHTLCMy8VnhFHSIDKwak5wi8WQd6gtR7YLwjTmKsWLo/r/PGqfPt9VbTfNQDierPt+BwuL4 N3SBjsTIQj363vQi9PK4rq5Q= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 11eae3e08de9d8e0; Tue, 01 Dec 2026 05:27:43 +0000 X-Mizu-Trace-ID: 11eae3e08de9d8e0 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>, 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: <20261130031647.45247-1-juanagusnicco@gmail.com>