From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5EF625F54E; Tue, 13 Feb 2024 17:25:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845151; cv=none; b=e8/cEGVyYU6UVgDwK6qYnu7RE0ql6z6UQk+PkwY3R7+FPAY8G+sDX7pxP+ykBF76iiVyJ5QGNsvxFQB9uIAX2H2T6oKuHo1uZQqHq0dzrfziEURyTx/X2/RnLrAhdCbqC7Bko9yyShXjI7Lf6OGD7ngotVXXxxBdH3IurZj6OVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845151; c=relaxed/simple; bh=pMg+P8bcL7jGFEF+euub2NCvEqWL8GKSiGUs0oJf/Ho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8I9Va5zi3j2TQ3qbqYMMgtSWh9lS+eXrhpw+Me1UP6fmbTGogxGNSPRNZRAqC+rgfL5eT6DgZUmx6LmB0srhB2hPPUIxm+JRafKsUJwiQ/u+pi4bNYPV8w8p1cuOK9LRMuy5n/vhFuhzD/loz1FW20NYobQkdIch7ySYf9zQKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=j+v9Le+d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="j+v9Le+d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6216C433C7; Tue, 13 Feb 2024 17:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707845151; bh=pMg+P8bcL7jGFEF+euub2NCvEqWL8GKSiGUs0oJf/Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+v9Le+dWzL/dU5uHp6Y0Stig3QY497X3wn3McuPq/kbuZLUol2G9oUuSTVhKn8mo 4sA0GlU6sEWmnxxuRI2vpZATW5h9B/zCu3iu3l13MuS6PMCeu2OZQaa7gVYqyxveOb atC9eFfEpDm9KTNaABrZPdVlvawoGM4NZ6XCI27c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 34/64] netfilter: nft_compat: restrict match/target protocol to u16 Date: Tue, 13 Feb 2024 18:21:20 +0100 Message-ID: <20240213171845.822609890@linuxfoundation.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240213171844.702064831@linuxfoundation.org> References: <20240213171844.702064831@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Pablo Neira Ayuso [ Upstream commit d694b754894c93fb4d71a7f3699439dec111decc ] xt_check_{match,target} expects u16, but NFTA_RULE_COMPAT_PROTO is u32. NLA_POLICY_MAX(NLA_BE32, 65535) cannot be used because .max in nla_policy is s16, see 3e48be05f3c7 ("netlink: add attribute range validation to policy"). Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_compat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c index 05862b3ea33b..e1623fbf3654 100644 --- a/net/netfilter/nft_compat.c +++ b/net/netfilter/nft_compat.c @@ -200,6 +200,7 @@ static const struct nla_policy nft_rule_compat_policy[NFTA_RULE_COMPAT_MAX + 1] static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv) { struct nlattr *tb[NFTA_RULE_COMPAT_MAX+1]; + u32 l4proto; u32 flags; int err; @@ -218,7 +219,12 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv) if (flags & NFT_RULE_COMPAT_F_INV) *inv = true; - *proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO])); + l4proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO])); + if (l4proto > U16_MAX) + return -EINVAL; + + *proto = l4proto; + return 0; } -- 2.43.0