Skip to content

Commit 2a53bfb

Browse files
aborreroummakynes
authored andcommitted
netfilter: nft_ct: fix unconditional dump of 'dir' attr
We want to make sure that the information that we get from the kernel can be reinjected without troubles. The kernel shouldn't return an attribute that is not required, or even prohibited. Dumping unconditionally NFTA_CT_DIRECTION could lead an application in userspace to interpret that the attribute was originally set, while it was not. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 2a97135 commit 2a53bfb

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎net/netfilter/nft_ct.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,19 @@ static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr)
311311
goto nla_put_failure;
312312
if (nla_put_be32(skb, NFTA_CT_KEY, htonl(priv->key)))
313313
goto nla_put_failure;
314-
if (nla_put_u8(skb, NFTA_CT_DIRECTION, priv->dir))
315-
goto nla_put_failure;
314+
315+
switch (priv->key) {
316+
case NFT_CT_PROTOCOL:
317+
case NFT_CT_SRC:
318+
case NFT_CT_DST:
319+
case NFT_CT_PROTO_SRC:
320+
case NFT_CT_PROTO_DST:
321+
if (nla_put_u8(skb, NFTA_CT_DIRECTION, priv->dir))
322+
goto nla_put_failure;
323+
default:
324+
break;
325+
}
326+
316327
return 0;
317328

318329
nla_put_failure:

0 commit comments

Comments
 (0)