Article View: linux.kernel.netdev
Article #8255Re: [PATCH] seg6: fix OOB read in advance_nextseg when segments_left is 0
From: Gabriel Goller
Date: Wed, 28 Oct 2026 14:11
Date: Wed, 28 Oct 2026 14:11
46 lines
9084 bytes
9084 bytes
On 28.10.2026 19:31, Tang Bin wrote:
> advance_nextseg() decrements srh->segments_left and uses it to index
> srh->segments without checking it is non-zero. seg6_validate_srh() permits
> segments_left == 0, so a packet with SRH segments_left==0 reaching an End*
> action underflows the u8 (255) and reads srh->segments[255] (~4KB out of
> bounds); the read bytes are then used as the new IPv6 destination address
> (info leak) or crash on unmapped memory. The decap path
> (decap_and_validate) already checks segments_left > 0, but the standard
> End/End.X/End.T/End.B6.Encap/End.BPF paths do not. Reject segments_left ==
> 0 before decrementing.
>
> Fixes: d7a669dd2f8b ("ipv6: sr: add helper functions for seg6local")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
> net/ipv6/seg6_local.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 53f7b2452..1d8312467 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -310,6 +310,10 @@ static struct ipv6_sr_hdr *advance_nextseg(struct sk_buff *skb,
> /* skb_ensure_writable() may change skb pointers; evaluate srh again */
> srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);
>
> + if (srh->segments_left == 0) {
> + *reason = SKB_DROP_REASON_NOT_SPECIFIED;
> + return NULL;
> + }
> srh->segments_left--;
> addr = srh->segments + srh->segments_left;
> ipv6_hdr(skb)->daddr = *addr;
> --
> 2.52.0.windows.1
Can you show a codepath where it is possible to call advance_nextseg() with
srh->segments_left being 0?
End/End.X/End.T/End.B6.Encap/End.BPF behaviors call get_and_validate_srh(),
which calls seg6_get_srh(skb, IP6_FH_F_SKIP_RH), which uses ipv6_find_hdr(),
which skips all the segments_left=0 headers.
Thanks,
Gabriel
Technical Details
Message-ID:
<auIA8TfNYq8XuD_i@luna.proxmox.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352872-linux-kernel-netdev=dewy.ruReferences:
<20261028113141.2111-1-tangbin@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352872-linux-kernel-netdev=dewy.ru From: g.goller@proxmox.com (Gabriel Goller) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] seg6: fix OOB read in advance_nextseg when segments_left is 0 Date: Wed, 28 Oct 2026 15:11:43 +0100 Organization: Usenet Network Message-ID: <auIA8TfNYq8XuD_i@luna.proxmox.com> References: <20261028113141.2111-1-tangbin@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Injection-Info: usenet.network; logging-data="1785993"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YIxaZwbWgo+yWaL4n3ZtoO72Lkc= sha256:OTTlRE8Wiaxw/K751ZyHX5xS3WiyHDkgPer91cx7JPk= sha1:I2WmF+w+AKWS6Ek4Nm+dm3419Ik= sha256:zH8KahhrcqXx8pz4aOFWE4YYgof2ZRqu8SHb8jsQZYs= 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 55A10125C36; Wed, 28 Oct 2026 17:17:23 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.95 X-Spam-Status: No, score=-2.95 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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-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 ALg5c_gKRyJ6; Wed, 28 Oct 2026 17:17:20 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-352872-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=proxmox.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 87131125C35; Wed, 28 Oct 2026 17:17:16 +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 BA7EA2CE0F; Wed, 28 Oct 2026 14:11:57 +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=1793196717; b=vK0HIS91Jz8jeieuSgOOBQZTMJd7cookukRBFtEe78hGZdUZpnWT5JYIsqoYPmRPSvsZ 1am6n4YGcMnKUEzkB+g5+DNfNVRQkYPp1yNd7bn7b8ak+4XegCcVTaBg5eh8rJR/szB0u iGI7TYQIVwCX6SfKYpd1PV7QHphNFmS2WPY25n+HPEjgdHSHrinaDgGzow617oF6P7pPc eEwVEv8ElVdOelU6PSZ//3J45l93EZrRvyzZY/DMeXeIUrY67uu329hFJNaxstUCx5AYY dyq3PSQzV510faUpvuoZM8OacnSCBEqsLHYsxB8vrnAVfXE2FRZHyPSBCSSKSe6ikkQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793196717; h=X-Original-To:Received:DMARC-Filter:Received: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:User-Agent: X-Bm-Milter-Handled:X-Bm-Transport-Timestamp; bh=Oas1iDvhjflqMxlRkG543vYH9mLSvNdodcghSDCtqRs=; b=ExdNaJysojQUxxitEAdKlSbrG6dhaP4QG0zmXlGHkqfBZbrhySfrWbdaS5Q8MvT/mOtj 6M35a5s0C11hzTHx2H4udSWmZDfklFxAclVW4BNlEG5uCgu15zG3Lz2I67cx09xDd/IdE gNTV4iZYZtk/4laKopS1I0mSm9VhCFKwFiuhBNaD3BffznCPri8Ycj9kTZJeM0BGVODom cHyVEArMYQwa4HItam/t8l8Xvpgz+l5oJ7wueCpMtUGd+n3S6K4UD7YVWit1paGe2gO4Y 9wrKTvlE76LiPGQgdMnjB/+yVqU3rn16U5h16sJxJN7Hlaq8h5wSpeq/o9a4itJtwXQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.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 9BA40606A31F; Wed, 28 Oct 2026 14:11:57 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=94.136.29.106 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793196709; b=B0yaMXTykCLgf0VEIUJnXAA7SCE6yZtBaxtwL4hkRiHYEuly8l8wNppZW5VKjoqdO+3p mWeZxVb7UqTNofO7yp3yG1NLI90u42Fj/o1Rl9CbQ8UY8ZQ0d6XykGEFIHJ/muIwapJen lrQGPt7V0R7BVBu47w5z6hIENz5lktmIzxOl0jhBEB+IyGYbNjF7O4Zq/U//JZ5ycqYtg 05xCwus1rH0hhPQGo0JH4Bg6FmgU3blRcC3WwV4efcwMbZaR4rIg1Wxbp1TvYm7rYjLR5 1g+ITaX9Uwp9Whr+zZoVbasQDaDuXXRxSkUEgEzA9qa/v7IEj92f7pAtgHxrrqdZb2g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793196709; h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Bm-Milter-Handled:X-Bm-Transport-Timestamp; bh=Oas1iDvhjflqMxlRkG543vYH9mLSvNdodcghSDCtqRs=; b=XIbori+3vzNr9OobAqGnVnhomwk2ml/0FLbnc3EzNnK+l+UFJkheqoR5R7Z+6RobBGn7 UHR1mbjVe+Su1QyeobFcUbTnd3ETKbSJDqa6QBPK62eo3JiSvgk4cBNRKbvI8WcLi1HOW /d7GLVwfp06i84IySu4fUiQks8/cuV4HJNLdo6b+G1B0ZA+AeU3vOWPV5xhqGXmvxqgcF wV01SD7013ufbCEZSyMjwmpGZxz69fNgpsErAuLP2mfkL4odzVzOEl9BUXPTHNoVRTU+j U3iG9rSIH34HNcNy9hdHdntggYJCG07JsxfJiTXCpNFzjqDpNFxKbvKZjC4gc12o3Cw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.com; arc=none smtp.remote-ip=94.136.29.106 X-Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8E91606A31A; Wed, 28 Oct 2026 14:11:47 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D8E91606A31A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proxmox.com X-Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1AF694383A; Wed, 28 Oct 2026 15:11:46 +0100 (CET) X-Cc: andrea.mayer@uniroma2.it, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org 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: <20261028113141.2111-1-tangbin@cmss.chinamobile.com> X-User-Agent: NeoMutt/20260504 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793196704580