Skip to content

Commit 0617c3d

Browse files
committed
netfilter: nf_tables: reject invalid set policy
Report -EINVAL in case userspace provides a unsupported set backend policy. Fixes: c50b960 ("netfilter: nf_tables: implement proper set selection") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent ea937f7 commit 0617c3d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5048,8 +5048,16 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info,
50485048
}
50495049

50505050
desc.policy = NFT_SET_POL_PERFORMANCE;
5051-
if (nla[NFTA_SET_POLICY] != NULL)
5051+
if (nla[NFTA_SET_POLICY] != NULL) {
50525052
desc.policy = ntohl(nla_get_be32(nla[NFTA_SET_POLICY]));
5053+
switch (desc.policy) {
5054+
case NFT_SET_POL_PERFORMANCE:
5055+
case NFT_SET_POL_MEMORY:
5056+
break;
5057+
default:
5058+
return -EOPNOTSUPP;
5059+
}
5060+
}
50535061

50545062
if (nla[NFTA_SET_DESC] != NULL) {
50555063
err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]);

0 commit comments

Comments
 (0)