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 55CFF3B9D9D; Tue, 21 Jul 2026 21:36:20 +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=1784669781; cv=none; b=hU8hGAXVHDWnqihcdoIKwRHlQFrCk7wA3Ngk31/oAtT/6uf/EHpyhjNRuVqqmK+qljkw6+i0z+oGzLmb+4FjlIZzGiOxKK9cIc0NPG7xP1tV5EA8EnYKIXs5YG6UKIfBZP3sETKt/hmaUXkGEJ7bG4EiJnZ7WNhTqo3fbhqNinY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669781; c=relaxed/simple; bh=uoYGbVnz78uDOopF2wOP5MHPC90ARteONj8hkEgGLzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ke2Cutvp4DH4eMtiVDWGOoKgpjH5+nGiGFrMYXQh1A8WtWQJNn9FNsL7pDs+x/tqbVrSerYXjSZcZTzX3K+1LvakYMf95sRuWioiERRzyY4InkIawaJQtg7L4Yex/CnjU7B+4O2zA1cNLPX18XzwBkGpRKPn1eK94QE0LhJ6Dl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YLN7tY3j; 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="YLN7tY3j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2BDA1F000E9; Tue, 21 Jul 2026 21:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784669780; bh=eB5dbMUFexMSO3usr1xGoMSHTXB6GCNfXTQ3bRJqwMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YLN7tY3jwY5zFH1DBS0tpHnrT0tjWZu4WJGAglhEs1vvCYLbbCRGIlD64f0LTtk/x FLK8A+bco6Sv9ImIAjrJJdVmhQalvqHKtCVrDsN6+3xhfFzAnSh6D17rAAG5pMMlv+ kxuY/ifHa2VQi9mz+ylG2ViaT5GA72DcZtBf/l4I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Tan , Yifan Wu , Juefei Pu , Zhengchuan Liang , Xin Liu , Wyatt Feng , Ren Wei , Florian Westphal , Sasha Levin Subject: [PATCH 6.1 0683/1067] netfilter: xt_u32: reject invalid shift counts Date: Tue, 21 Jul 2026 17:21:24 +0200 Message-ID: <20260721152439.875174505@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wyatt Feng [ Upstream commit 64cdf7d30ac18e43df6c48004435febb965809a8 ] u32_match_it() executes rule-supplied shift operands on a 32-bit value. A malformed u32 rule can provide a shift count of 32 or more, triggering an undefined shift out-of-bounds during packet evaluation. Validate XT_U32_LEFTSH and XT_U32_RIGHTSH operands in u32_mt_checkentry() and reject malformed rules before they reach the packet path. Fixes: 1b50b8a371e9 ("[NETFILTER]: Add u32 match") Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Zhengchuan Liang Reported-by: Xin Liu Assisted-by: Codex:GPT-5.4 Signed-off-by: Wyatt Feng Signed-off-by: Ren Wei Signed-off-by: Florian Westphal Signed-off-by: Sasha Levin --- net/netfilter/xt_u32.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/netfilter/xt_u32.c b/net/netfilter/xt_u32.c index 117d4615d6684c..ec1a21e3b6e2c3 100644 --- a/net/netfilter/xt_u32.c +++ b/net/netfilter/xt_u32.c @@ -100,7 +100,7 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par) { const struct xt_u32 *data = par->matchinfo; const struct xt_u32_test *ct; - unsigned int i; + unsigned int i, j; if (data->ntests > ARRAY_SIZE(data->tests)) return -EINVAL; @@ -111,6 +111,16 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par) if (ct->nnums > ARRAY_SIZE(ct->location) || ct->nvalues > ARRAY_SIZE(ct->value)) return -EINVAL; + + for (j = 1; j < ct->nnums; ++j) { + switch (ct->location[j].nextop) { + case XT_U32_LEFTSH: + case XT_U32_RIGHTSH: + if (ct->location[j].number >= 32) + return -EINVAL; + break; + } + } } return 0; -- 2.53.0