summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2024-02-01 23:33:29 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-23 08:12:54 +0100
commit56fb2bf4ab8c91a2e078553497b6c5b2f1dac699 (patch)
treed6d552c798c75d7156aac50819a2f7fc0cc8ecdd
parent4fdb14ba89faff6e6969a4dffdc8e54235d6e5ed (diff)
downloadlinux-stable-56fb2bf4ab8c91a2e078553497b6c5b2f1dac699.tar.gz
linux-stable-56fb2bf4ab8c91a2e078553497b6c5b2f1dac699.tar.bz2
linux-stable-56fb2bf4ab8c91a2e078553497b6c5b2f1dac699.zip
netfilter: nft_compat: reject unused compat flag
[ Upstream commit 292781c3c5485ce33bd22b2ef1b2bed709b4d672 ] Flag (1 << 0) is ignored is set, never used, reject it it with EINVAL instead. Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h2
-rw-r--r--net/netfilter/nft_compat.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index cc00be102b9f..39774870c864 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -238,9 +238,11 @@ enum nft_rule_attributes {
/**
* enum nft_rule_compat_flags - nf_tables rule compat flags
*
+ * @NFT_RULE_COMPAT_F_UNUSED: unused
* @NFT_RULE_COMPAT_F_INV: invert the check result
*/
enum nft_rule_compat_flags {
+ NFT_RULE_COMPAT_F_UNUSED = (1 << 0),
NFT_RULE_COMPAT_F_INV = (1 << 1),
NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
};
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 2846d64659f2..95af1dbc28c1 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -207,7 +207,8 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
return -EINVAL;
flags = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_FLAGS]));
- if (flags & ~NFT_RULE_COMPAT_F_MASK)
+ if (flags & NFT_RULE_COMPAT_F_UNUSED ||
+ flags & ~NFT_RULE_COMPAT_F_MASK)
return -EINVAL;
if (flags & NFT_RULE_COMPAT_F_INV)
*inv = true;