From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796008615; b=taiHhdPLfSCmKjxSJ78yvnSAta2QrOVAeQWmRtwoBGgwm4QS7M1QawNYarrpktMg0uQz cR8V5yqo77a3hgaU15vQSrsDb/p3VHISIh5HntY2sTgFwSWdBcOzn0wDWc/j1mBqVdFeQ JV12v5yUAHzbNLs7PkFLLFEQK2Xg17Fa5Xy+y6zFpNwV+8qX9s7z3YVKOQR1Bx5gH8het rNLGrc9Hd2TIoq0vdtxtde58Uuu57GS38PzRV6ETMMgRYbt1Ue+zVCiWceRZqmDdYvN3z FnBCfr7wW0IWZzyq3+M3iuisYpX7YCpUXrCgc567lK+Y0lAb5ShnmcAv2jTg9gCAbVw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796008615; 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=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=; b=mq9H68pNL0LWEfzdo5fCqFCCE5wX5q/sCAL3i5DqqURBqPc0NxUBP/8Qn3v2oqm1/t9U X8zzZj7nlVqpc8lu9w6HgO56KicNVTtE6IWJ9uEmKp/PF8ktrlHnK2aAx8W3qLgEo7xRj SCRHZ3lIM+0wYesZKaBSq7Uw+SCp2ds+wLxNFMlJEpx2TtyojvcJFdUC2fsY0m3kFGahE rGqEY/uJTk9otSd0/yOwZcpfiUw/VKwuL53PKjmR0K0AxfrY2V+5hPxSAQlWFd/YOITZF zH+2Zi1rQjpq46T9K1nnjWcLhCtUg1/4d+DzWhjFwn9+Oh9n0IwI4MYb3GwypL8dvng== 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="s+e/YDuC"; arc=none smtp.remote-ip=74.125.224.54 Received: from mail-yx1-f54.google.com (mail-yx1-f54.google.com [74.125.224.54]) (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 CE093606A31C for ; Mon, 30 Nov 2026 03:16:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE093606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=s+e/YDuC Received: by mail-yx1-f54.google.com with SMTP id 956f58d0204a3-67db0791748so11170126d50.1 for ; Sun, 29 Nov 2026 19:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796008614; x=1796613414; 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=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=; b=s+e/YDuCWapnIC2WMVibT8bqa4owPsiJJYx6sh3gOlelKjL/E+TJFLXXD27b9FYfe1 w0D3BpuOosKS1gGM/LIpJjVK++Rt7X8mIIm2uQdRokcp8wcoUzlr6dvc+Jxn/puWoAZm siHFMwD1y1Xzp5ay7uw7mp9Y3rS7FEb+z2MBr310jzQFi6SKwVd1XtY+95yhU18fB9MN qK+a2ObjV+X63AoFcrB42WSESHQ1PsOwDgL8HymnGc6RevTH2Ez8u0Xbsa/x+HrIiQ/f i9KFYNWPrCe20O1iKo78Cz1QvSIZuz8VEWzDedrImzs0TG16BccvHZjFJbIyaqPVQtyc unpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796008614; x=1796613414; 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=0SLst8MCTbY9HgL1wiIOdkWOee+UzrNeHXNx68oFx7A=; b=0GT8/BuoYC3Olu8lcYfcN3PQMdaC4eI/fTnv6Ww/vcYP/GrPD3A/6HdN7B/2fUKDI/ e/Q4SiKnT2fKgy4NcU7wAuelqcglQtTciiZKny3TTNhWLxEKvSf04K116ygAVQWdyYhH 002vtAxfdBbLaoug+UFOWOX2OgTp/iBFc0QAwP5iZkdd/XHLAoQXjmQJhdnWm7V4NQ8H 5BbVqifBATHmudkB89MgRNwlV6m6snMe2mPWR+tX3toDOgNk2w2NNmx4Y9s9YFBedpQN VMZ1D4H3xZmJTJeypOmkdieKHhum5uMs0WhPvmD6O27/oeDdWjp1cOpe+BEByk2/8WYp 6YEQ== X-Gm-Message-State: APuU4Z+fG5Lkn7JPqXNS6BE9c/O4KfjjkOM1Fat0OQZk2OtfXoMB/bdr RtQA2doG2pQqZVvtW4Z81DgU3VUfomJ2xlMKN8MUuvptkZbW44//Avy9 X-Gm-Gg: AZFdTZeJgcwbp7Cy7bGqB9gL5Z08lWtioAItqmti0ubv7MsrKyLFB1A5OZDu/ovAw3x dv49+43QOTRECfILmMTR2QUUAgQTehwKIVL55aqyBxK1mwQcve8wKDXtIrhpauaBhJ8dNCJqsYA yjCF3RpvCleMxRddbW0GBP9rWt9/WaHbk6++MNAhzq73rsr9e0pfPpK4IqLLGiXku6lIxt/MvgD Edh2tj3ZcPj2ehJKi7UchFrCIcSi5trTlZ0tGCCuQg5MKUNWwUwiqzNTyQj7VsJFNSQ/lrlgXmk TvKw086EYUfje6LaLd9+U7rLXVLMhqSLnA/2uoTCJJiGBVXkR9/HJWi9TOcPvbd/8XThTRGnBCi 05fg8ctRUL2yZtAM375k0vMLjTMPxBrF+o29P+twq6p+BP2DDJfM2qFk46e+m6/IzIygRVk0dVK Q+Rdub0+UIb0yPdAyavuj+v6aUEoZ5b/eKAFGeTkS5E7+zekK/qZD0Da7l95aa8E00r8BYW7OIb z8A+gUHTGrTR1R9UVIClWwJ28ZrQ0v7P/LBsvveJHecPqEuB9T9+75UR7S5fWn9nS3HygXt/t4G 96cPWAUuhZcZt6TH5StCyYb9j7wh7agvlOIQuToTbid0lW86qYJiNVriR124dTlfNogKUV4XnQ= = X-Received: by 2002:a05:690e:43ce:b0:67c:2a1f:84ae with SMTP id 956f58d0204a3-67df4456424mr7934571d50.83.1796008613797; Sun, 29 Nov 2026 19:16:53 -0800 (PST) Received: from VPN-156-19.vpn.usf.edu ([2607:fe50:0:f802::4046]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df330fe0esm14738712d50.8.2026.11.29.19.16.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 19:16:52 -0800 (PST) From: Juan Agustin Niccolini To: Andrea Mayer , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: netdev@vger.kernel.org, Simon Horman , Hangbin Liu , David Ahern , Julien Massonneau Subject: [PATCH net] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read Date: Sun, 29 Nov 2026 22:16:47 -0500 Message-ID: <20261130031647.45247-1-juanagusnicco@gmail.com> X-Mailer: git-send-email 2.53.0 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-Transfer-Encoding: 8bit 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. 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 --- 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