Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nft_ct: fix l3num expectations with inet pseudo family

Following is rejected but should be allowed:

table inet t {
ct expectation exp1 {
[..]
l3proto ip

Valid combos are:
table ip t, l3proto ip
table ip6 t, l3proto ip6
table inet t, l3proto ip OR l3proto ip6

Disallow inet pseudeo family, the l3num must be a on-wire protocol known
to conntrack.

Retain NFPROTO_INET case to make it clear its rejected
intentionally rather as oversight.

Fixes: 8059918a1377 ("netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
99993789 5f4fc4bd

+5 -6
+5 -6
net/netfilter/nft_ct.c
··· 1256 1256 switch (priv->l3num) { 1257 1257 case NFPROTO_IPV4: 1258 1258 case NFPROTO_IPV6: 1259 - if (priv->l3num != ctx->family) 1260 - return -EINVAL; 1259 + if (priv->l3num == ctx->family || ctx->family == NFPROTO_INET) 1260 + break; 1261 1261 1262 - fallthrough; 1263 - case NFPROTO_INET: 1264 - break; 1262 + return -EINVAL; 1263 + case NFPROTO_INET: /* tuple.src.l3num supports NFPROTO_IPV4/6 only */ 1265 1264 default: 1266 - return -EOPNOTSUPP; 1265 + return -EAFNOSUPPORT; 1267 1266 } 1268 1267 1269 1268 priv->l4proto = nla_get_u8(tb[NFTA_CT_EXPECT_L4PROTO]);