netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 02/18] netfilter: nft_ct: fix unconditional dump of 'dir' attr
Date: Fri,  7 Feb 2014 18:41:28 +0100	[thread overview]
Message-ID: <1391794904-4017-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1391794904-4017-1-git-send-email-pablo@netfilter.org>

From: Arturo Borrero <arturo.borrero.glez@gmail.com>

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>
---
 net/netfilter/nft_ct.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 917052e..feaf0f3 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -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:
-- 
1.7.10.4


  parent reply	other threads:[~2014-02-07 17:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 17:41 [PATCH 00/18] Netfilter/nftables/IPVS fixes for net Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 01/18] ipvs: fix AF assignment in ip_vs_conn_new() Pablo Neira Ayuso
2014-02-07 17:41 ` Pablo Neira Ayuso [this message]
2014-02-07 17:41 ` [PATCH 03/18] netfilter: nf_tables: fix oops when deleting a chain with references Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 04/18] netfilter: nf_conntrack: fix RCU race in nf_conntrack_find_get Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 05/18] netfilter: nf_nat_h323: fix crash in nf_ct_unlink_expect_report() Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 06/18] netfilter: nf_conntrack: don't release a conntrack with non-zero refcnt Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 07/18] netfilter: nf_tables: fix overrun in nf_tables_set_alloc_name() Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 08/18] netfilter: nf_tables: fix potential oops when dumping sets Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 09/18] netfilter: nft_ct: fix missing NFT_CT_L3PROTOCOL key in validity checks Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 10/18] netfilter: nf_tables: add AF specific expression support Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 11/18] netfilter: nft_reject: split up reject module into IPv4 and IPv6 specifc parts Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 12/18] netfilter: nf_tables: add reject module for NFPROTO_INET Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 13/18] netfilter: nf_tables: fix log/queue expressions " Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 14/18] netfilter: nf_tables: fix racy rule deletion Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 15/18] netfilter: nf_tables: do not allow NFT_SET_ELEM_INTERVAL_END flag and data Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 16/18] netfilter: nft_rbtree: fix data handling of end interval elements Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 17/18] netfilter: nf_tables: fix loop checking with " Pablo Neira Ayuso
2014-02-07 17:41 ` [PATCH 18/18] netfilter: nf_tables: unininline nft_trace_packet() Pablo Neira Ayuso
2014-02-09 22:20 ` [PATCH 00/18] Netfilter/nftables/IPVS fixes for net David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391794904-4017-3-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).