From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796233850; b=yDWFNGEFo2eddvJ4djB/7dW4yaahBDjlU0dI1M6j5QnjJt9mGZ52MDyPvL/ScfKRhChh K4UqUbRs/ZtlhrJyXxnIK5ea+p3xUpmslc0Lx4LYGT9sYDutRuvLnXsfJlGJoGhv3pq9t bgpOw/ZFAKn+xEUCI9xKp4VzfnowrpG8zpWF6ic1rd75hmWbyZgtP0Q5klbKUN+WJOimE EmRYIv/4Bv2AwZyegNVt6HLhuQm9eOp0f2nghCmBY6990v4ZjNny9I/OBm1VKt32+kvJf GP6izez2O5+rUGYKftjJMfUkQVty68aQrjBlD8Mo9tj5egQrbycGYtJ0KR+8x/XDKCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233850; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=; b=fnolWLL28gndKW2/c2dxCE0HM5/AB7EB6AJCeEIlGORILHPuUg9SNN0dk/P/lKucNMr4 jSY+VbBLU64ss5MjmNv6DzUAA/wLEFHSd3aNORs3gLFqWH+sojbzoORHJwdjM92gZXpQX /xwRO65RMIn7/6lFHjCEZ6YDMSR1CebdMYvtUYKcsdod8nvfnoLx92SsHuSYGRQdiiyWG +u1N9DGiAxADbv+xiwKzjJEwvqWsMXBnvOoNfwW46zy8hMjtNHmwT/jSQYPgGc+7fme/M YUoiMGb8FssBrQt3gc7LVaRcjBAAUhdab8qYPLGNhYTMDoW17q7L7twjAtvUFkHgKfA== 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=hPa9dOpB; arc=none smtp.remote-ip=209.85.218.51 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 0478D606A322 for ; Wed, 2 Dec 2026 17:50:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0478D606A322 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=hPa9dOpB Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-c4395d31228so2346823666b.1 for ; Wed, 02 Dec 2026 09:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796233848; x=1796838648; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=; b=hPa9dOpBcOs+wybj5dSvVCX3wmIEvJTB6ey63XA1MlPJinYVPLZ//AvXZovTmCMtKe gDXEuJYxaPsRnqoPdA9aD6/gmAXhnlzhmOEV+atCndYbCsHKAAVNPBY+T/0yckc1h94B c4Ij07ywvXwa35m8c6k07DYxTiUkBUUGoCNc4CfmXp+DvsBo8pmGeSrKrvvvSNnJSBF6 xJNp0OAcsR+o1Nc3n4NuEk0fJd8u5ShmlN6/ixDN/TwkYBZGV7pfLxaEelh6Ss4470hK eTqO9axQtu9JwYXEFfGEbAYzi2L3DQBp+amHC+pMa8Vb6xI751ccJPWaOfPdcjkexTAU R9iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796233848; x=1796838648; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BwKNt6NbjQCGcD/b2mI1N8YOv8fi8CprdHVWTa/CDko=; b=qXdzB+MVGM0DNmoeVcSm28vSMT9uuX4eshJPFDLT22zcPkFSHcSVfTq1Y5XFKfO7F+ pVnlX9eUi6czVQqUJgdvzFICG4evshfgohizdGUSpWbY2uDM1dOqhmwufUxApHORztey QpMzHv+VubU8ejwDjGYEAHXuw7X9FlVvrBDVLsx4JcmIzss+7ExOLrJnaSf6SeDoYWNs I9X7XkbdyZaePlb4PO5nFQVRnGfUl6ny7HfFxfgQP/qzVuoqSXlgy1AJ9eNlOA7z6cPG Zh6HjCWGTLAKe3c62o97cb+2fq/YKKCHmWnEux5Lqa+3raH8F8JnmCkPGko8YYag2DNS a0xQ== X-Gm-Message-State: APuU4Z/iiybxZ2IKoXAjKDrF1x9Op6DuSmfCVQk6Kv7cMgRYgxnD6GTj v4wxcaabcBXEk4WpjEBaOQPM73UE8ew3Bz59/qHXZsMW/1y9BaEkKFO6 X-Gm-Gg: AZFdTZfSE1+leKMW6DRJ75EZxiTaVPVX9OsNfrh9gy45nVwrIAoD3TGndMdw854Osz2 rEO6w+J/RPrf9AHfmO7wRShelPN8dPQ2nZclN4DkkQWuo1i8ihqNSBIW735DJ6s2tuJkByrH2fN FiiUQNXSSXlxKAu2eVOLTErIt6dQjbR6z9UivZd7KLlwgwMH/8tmF9m/GUqLTH90MJhPDZkEU9S J4gXznoXCpkSKySBs87LP5IvC6Ljf4Pffv4ICUKrJnNqBjMxob3/6dxJOXZE9NU188h0XxqCEOS VlrlbEP03iggvx/yHDQNjN0+XUZOCRxyeoOcdc5H2A22VIGOOzKH7AmOp+T9q7X8thhInRK74OY DjGpPOXj7jeP7qLV3hhl7XLXPGV+mDnB7Hyf2JzIzw3f2YJyiAyOgSpx6Do0nxqXNaF9KKcKI1o 5XccypqKgMKyf2YfvY7aoSH1SytDv4NilbHAl9xE2RmznvIKo9gftBAZx4jy7PL8HYrOAB60VBU XcOUn9unibsnB83SCkjHF/Ranmrs/MbK5DLjkjtqzy3y9loByW01aajtQni0tucMD7rAyk0aJh6 MO4ihayT9WWKNV2hjFeuUrkeQSarUITQ9CX+EPKU7u04VsCAIlr+sQbNdPa72qSjveE14ScfocY TOJ0= X-Received: by 2002:a17:907:d02:b0:c51:558c:7654 with SMTP id a640c23a62f3a-c51558cefc9mr3450301666b.7.1796233848127; Wed, 02 Dec 2026 09:50:48 -0800 (PST) Received: from ?IPV6:2a02:a03f:a75e:9a00:3ec:6081:8381:79fc? ([2a02:a03f:a75e:9a00:3ec:6081:8381:79fc]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513aea3537sm1330196866b.36.2026.12.02.09.50.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 09:50:47 -0800 (PST) Message-ID: <0315fe49-6ba9-4d85-8719-5ae49b982e3b@gmail.com> Date: Wed, 2 Dec 2026 18:50:47 +0100 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2] seg6: check segments_left in the pulled SRH to fix an out-of-bounds read To: Juan Agustin Niccolini , Andrea Mayer , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: netdev@vger.kernel.org, Simon Horman , Hangbin Liu , Gabriel Goller , David Ahern , Julien Massonneau References: <20261202063404.6809-1-juanagusnicco@gmail.com> Content-Language: en-US From: Justin Iurman In-Reply-To: <20261202063404.6809-1-juanagusnicco@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/2/26 07:34, 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 > Reviewed-by: Hangbin Liu > --- > 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; Reviewed-by: Justin Iurman