Skip to content

Commit

Permalink
netfilter: nft_ct: fix unconditional dump of 'dir' attr
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arturo Borrero authored and Pablo Neira Ayuso committed Feb 5, 2014
1 parent 2a97135 commit 2a53bfb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions net/netfilter/nft_ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,19 @@ static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr)
goto nla_put_failure;
if (nla_put_be32(skb, NFTA_CT_KEY, htonl(priv->key)))
goto nla_put_failure;
if (nla_put_u8(skb, NFTA_CT_DIRECTION, priv->dir))
goto nla_put_failure;

switch (priv->key) {
case NFT_CT_PROTOCOL:
case NFT_CT_SRC:
case NFT_CT_DST:
case NFT_CT_PROTO_SRC:
case NFT_CT_PROTO_DST:
if (nla_put_u8(skb, NFTA_CT_DIRECTION, priv->dir))
goto nla_put_failure;
default:
break;
}

return 0;

nla_put_failure:
Expand Down

0 comments on commit 2a53bfb

Please sign in to comment.