Skip to content

Commit

Permalink
netfilter: nf_tables: reject invalid set policy
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ummakynes committed Jan 17, 2024
1 parent ea937f7 commit 0617c3d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5048,8 +5048,16 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info,
}

desc.policy = NFT_SET_POL_PERFORMANCE;
if (nla[NFTA_SET_POLICY] != NULL)
if (nla[NFTA_SET_POLICY] != NULL) {
desc.policy = ntohl(nla_get_be32(nla[NFTA_SET_POLICY]));
switch (desc.policy) {
case NFT_SET_POL_PERFORMANCE:
case NFT_SET_POL_MEMORY:
break;
default:
return -EOPNOTSUPP;
}
}

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

0 comments on commit 0617c3d

Please sign in to comment.