Skip to content

Commit 336e208

Browse files
ummakynessmb49
authored andcommitted
netfilter: nft_compat: reject unused compat flag
BugLink: https://bugs.launchpad.net/bugs/2059991 [ Upstream commit 292781c ] Flag (1 << 0) is ignored is set, never used, reject it it with EINVAL instead. Fixes: 0ca743a ("netfilter: nf_tables: add compatibility layer for x_tables") Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Portia Stephens <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 1629e45 commit 336e208

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ enum nft_rule_attributes {
284284
/**
285285
* enum nft_rule_compat_flags - nf_tables rule compat flags
286286
*
287+
* @NFT_RULE_COMPAT_F_UNUSED: unused
287288
* @NFT_RULE_COMPAT_F_INV: invert the check result
288289
*/
289290
enum nft_rule_compat_flags {
291+
NFT_RULE_COMPAT_F_UNUSED = (1 << 0),
290292
NFT_RULE_COMPAT_F_INV = (1 << 1),
291293
NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
292294
};

net/netfilter/nft_compat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
212212
return -EINVAL;
213213

214214
flags = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_FLAGS]));
215-
if (flags & ~NFT_RULE_COMPAT_F_MASK)
215+
if (flags & NFT_RULE_COMPAT_F_UNUSED ||
216+
flags & ~NFT_RULE_COMPAT_F_MASK)
216217
return -EINVAL;
217218
if (flags & NFT_RULE_COMPAT_F_INV)
218219
*inv = true;

0 commit comments

Comments
 (0)