From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.70 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== 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== 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 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 ; Wed, 2 Dec 2026 08:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95D5F606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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-Envelope-To: netdev@vger.kernel.org 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 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 Date: Wed, 2 Dec 2026 16:17:17 +0800 From: Hangbin Liu To: Juan Agustin Niccolini Cc: Andrea Mayer , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , netdev@vger.kernel.org, Simon Horman , Gabriel Goller , David Ahern , Julien Massonneau Subject: Re: [PATCH net v2] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read Message-ID: References: <20261202063404.6809-1-juanagusnicco@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202063404.6809-1-juanagusnicco@gmail.com> 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 > Signed-off-by: Juan Agustin Niccolini > --- > 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