Skip to content

Commit f342de4

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: reject QUEUE/DROP verdict parameters
This reverts commit e0abdad. core.c:nf_hook_slow assumes that the upper 16 bits of NF_DROP verdicts contain a valid errno, i.e. -EPERM, -EHOSTUNREACH or similar, or 0. Due to the reverted commit, its possible to provide a positive value, e.g. NF_ACCEPT (1), which results in use-after-free. Its not clear to me why this commit was made. NF_QUEUE is not used by nftables; "queue" rules in nftables will result in use of "nft_queue" expression. If we later need to allow specifiying errno values from userspace (do not know why), this has to call NF_DROP_GETERR and check that "err <= 0" holds true. Fixes: e0abdad ("netfilter: nf_tables: accept QUEUE/DROP verdict parameters") Cc: [email protected] Reported-by: Notselwyn <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent b462579 commit f342de4

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10992,16 +10992,10 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
1099210992
data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
1099310993

1099410994
switch (data->verdict.code) {
10995-
default:
10996-
switch (data->verdict.code & NF_VERDICT_MASK) {
10997-
case NF_ACCEPT:
10998-
case NF_DROP:
10999-
case NF_QUEUE:
11000-
break;
11001-
default:
11002-
return -EINVAL;
11003-
}
11004-
fallthrough;
10995+
case NF_ACCEPT:
10996+
case NF_DROP:
10997+
case NF_QUEUE:
10998+
break;
1100510999
case NFT_CONTINUE:
1100611000
case NFT_BREAK:
1100711001
case NFT_RETURN:
@@ -11036,6 +11030,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
1103611030

1103711031
data->verdict.chain = chain;
1103811032
break;
11033+
default:
11034+
return -EINVAL;
1103911035
}
1104011036

1104111037
desc->len = sizeof(data->verdict);

0 commit comments

Comments
 (0)