From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78CCD4343F1; Tue, 21 Jul 2026 19:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663214; cv=none; b=HY+xN/oolrlixsqYtqIf+Ij1MO0kGl/RAJ3xxSzrrGzC1laOqRncTIdSteicl7MdqoPWS7au8d3VFRphNnmQaAxjnH4vWY+lwc/3a8nQgG59xYE33foHMk8bJrKVyeAKYJ5FD9Ge52VH8W38MTieQmukTBY8E6fsOiyr7JtIkDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663214; c=relaxed/simple; bh=Z15iYBQ4u94Lfqqd2zDfF3J6FKsx1mKnwEX87530Gz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSnkvPVYTBgBipSbEzuwltdRfu50FEy8QtUMmnx+UvKs8ONW95DDK7CeIO3enQ617QEXEOKH/INVxT634xIFXILzWlLVSEJXPr6OQRtRnZ7pMoRqGRXBg0Uil8ipyqfx4qa1ryO4CCSt5uKbLZB8nbYaHL8rYBpUFaEcKNWpP64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xM+lxQzP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xM+lxQzP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B767F1F000E9; Tue, 21 Jul 2026 19:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663213; bh=spMiyfNtwUDAfxcSp13wE8IV5Dauw39sxp6/dxlrFYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xM+lxQzPDiunk2y8SnHUuGYHASAJ381BGsdq6eZ5oVh9MSRi3SSTHtUmV5+bKMX0L l7+5Ek6vYpn94sL8wq29bcuINXt6gOVB4+/bIbpG31XhD51wDuYI9n0DfCGPlzNtmB 8x+0wg6bKCVOFAkINjA057UFoLnk3lXlju1/ycAs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nuoqi Gui , Andrea Mayer , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 0694/1276] seg6: validate SRH length before reading fixed fields Date: Tue, 21 Jul 2026 17:18:57 +0200 Message-ID: <20260721152501.628305066@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nuoqi Gui [ Upstream commit a75d99f46bf21b45965ce39c5cfb3b8bb5ffb1aa ] seg6_validate_srh() reads fixed SRH fields such as srh->type and srh->hdrlen before checking that the supplied length covers the fixed struct ipv6_sr_hdr fields. The BPF SEG6 encap path reaches this with a BPF program-supplied pointer and length: bpf_lwt_push_encap() and the SEG6 local BPF END_B6 and END_B6_ENCAP actions call bpf_push_seg6_encap(), which forwards the length to seg6_validate_srh() with no minimum-size guard. A 2-byte SEG6 encap header can therefore make the validator read srh->type at offset 2 beyond the caller-supplied buffer. Reject lengths shorter than the fixed SRH at the top of seg6_validate_srh(), before any field is read. This fixes the BPF helper path and keeps the common validator robust. Fixes: fe94cc290f53 ("bpf: Add IPv6 Segment Routing helpers") Signed-off-by: Nuoqi Gui Reviewed-by: Andrea Mayer Link: https://patch.msgid.link/20260623-f01-17-seg6-srh-len-v2-1-2edc40e9e3e1@mails.tsinghua.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/seg6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c index 180da19c148c1d..5b57ea4fdda9f1 100644 --- a/net/ipv6/seg6.c +++ b/net/ipv6/seg6.c @@ -29,6 +29,9 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len, bool reduced) int max_last_entry; int trailing; + if (len < sizeof(*srh)) + return false; + if (srh->type != IPV6_SRCRT_TYPE_4) return false; -- 2.53.0