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 4A384241C8C; Sat, 30 May 2026 18:16:28 +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=1780164989; cv=none; b=efsRprhpk3VZzL+RU1Qn1E+jv7YkrNlKq/DRUrY7CWROwzP29fuIvCjBxYBopFOcnP0UwwOQc9ea/6/avE4mgT9ynOh6GvkgvRXzknuIcwwVA0MK03yVZKs3hEEYyTZJF4LOeQ9jc68Q0L4DqssxQBxAIabrKjEcmLoZgxK2ZHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164989; c=relaxed/simple; bh=lVqLVHGgd27+ETa1lbnRUdrAM/9I45zD5rWX5manRzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gAvdlFWegnZcaw//6pxjpfOLJI9zcdIi6IfHhHN5WVv3PJb6eiOFQQLNOcjD+szq1crfA570MRqTw2NLtE+pVAWfPMnI73pPFUOS2ShuwGqSdOfvWr3JmTaR6KOuefLkVNlGwF8jKQByeDv//Uo2tkIRJ3t3E2JZ/5MIR2qoXM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=deVnCgHt; 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="deVnCgHt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8809F1F00893; Sat, 30 May 2026 18:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164988; bh=LV4wTb0ISJb+4PuS62p67itgIR5ghOZvf36TYT2MHhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=deVnCgHtHtlw1wU2T8+44wCqH1+eaIshL4YlDOCpAUp0zCWmOEn+QWbBoUX5pA1IV qk3LxFJdC3I7PILEUb1D1ufy6roLWJir8TY+6Tgs8tArclJRsPoKWNxiIS50BXRxcK 1I1/3TPAJA4lI3LmJib2kvKNgvOB9vqN0cHMY8N8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , Zhengchuan Liang , Ren Wei , Pablo Neira Ayuso Subject: [PATCH 5.15 687/776] netfilter: ip6t_hbh: reject oversized option lists Date: Sat, 30 May 2026 18:06:41 +0200 Message-ID: <20260530160257.611946383@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhengchuan Liang commit 4322dcde6b4173c2d8e8e6118ed290794263bcc8 upstream. struct ip6t_opts stores at most IP6T_OPTS_OPTSNR option descriptors, but hbh_mt6_check() does not reject larger optsnr values supplied from userspace. Validate optsnr in the rule setup path so only match data that fits the fixed-size opts array can be installed. This follows the existing xtables pattern of rejecting invalid user-provided counts in checkentry() and keeps the packet matching path unchanged. `struct ip6t_opts` has a fixed `opts[IP6T_OPTS_OPTSNR]` array, where `IP6T_OPTS_OPTSNR` is 16, then off-by-one array access is possible: [ 137.924693][ T8692] UBSAN: array-index-out-of-bounds in ../net/ipv6/netfilter/ip6t_hbh.c:110:29 [ 137.926167][ T8692] index 16 is out of range for type '__u16 [16]' Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Signed-off-by: Zhengchuan Liang Signed-off-by: Ren Wei Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/ipv6/netfilter/ip6t_hbh.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/ipv6/netfilter/ip6t_hbh.c +++ b/net/ipv6/netfilter/ip6t_hbh.c @@ -168,6 +168,10 @@ static int hbh_mt6_check(const struct xt pr_debug("unknown flags %X\n", optsinfo->invflags); return -EINVAL; } + if (optsinfo->optsnr > IP6T_OPTS_OPTSNR) { + pr_debug("too many supported opts specified\n"); + return -EINVAL; + } if (optsinfo->flags & IP6T_OPTS_NSTRICT) { pr_debug("Not strict - not implemented");