netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement
@ 2015-05-16 18:50 Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Pablo Neira Ayuso
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

[ upstream commit 59900e0a019e7c2bdb7809a03ed5742d311b15b3 ]

In general, if a transaction object is added to the list successfully,
we can rely on the abort path to undo what we've done. This allows us to
simplify the error handling of the rule replacement path in
nf_tables_newrule().

This implicitly fixes an unnecessary removal of the old rule, which
needs to be left in place if we fail to replace.

Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 74e4b87..6ab7779 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2045,12 +2045,6 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
 
 err3:
 	list_del_rcu(&rule->list);
-	if (trans) {
-		list_del_rcu(&nft_trans_rule(trans)->list);
-		nft_rule_clear(net, nft_trans_rule(trans));
-		nft_trans_destroy(trans);
-		chain->use++;
-	}
 err2:
 	nf_tables_rule_destroy(&ctx, rule);
 err1:
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple()
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-05-19 11:31   ` Jiri Slaby
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: check for overflow of rule dlen field Pablo Neira Ayuso
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

From: Ian Wilson <iwilson@brocade.com>

[ upstream commit 78146572b9cd20452da47951812f35b1ad4906be ]

nfnl_cthelper_parse_tuple() is called from nfnl_cthelper_new(),
nfnl_cthelper_get() and nfnl_cthelper_del().  In each case they pass
a pointer to an nf_conntrack_tuple data structure local variable:

    struct nf_conntrack_tuple tuple;
    ...
    ret = nfnl_cthelper_parse_tuple(&tuple, tb[NFCTH_TUPLE]);

The problem is that this local variable is not initialized, and
nfnl_cthelper_parse_tuple() only initializes two fields: src.l3num and
dst.protonum.  This leaves all other fields with undefined values
based on whatever is on the stack:

    tuple->src.l3num = ntohs(nla_get_be16(tb[NFCTH_TUPLE_L3PROTONUM]));
    tuple->dst.protonum = nla_get_u8(tb[NFCTH_TUPLE_L4PROTONUM]);

The symptom observed was that when the rpc and tns helpers were added
then traffic to port 1536 was being sent to user-space.

Cc: <stable@vger.kernel.org> # 3.10.x
Cc: <stable@vger.kernel.org> # 3.12.x
Cc: <stable@vger.kernel.org> # 3.14.x
Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Ian Wilson <iwilson@brocade.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nfnetlink_cthelper.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index a5599fc..54330fb 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -77,6 +77,9 @@ nfnl_cthelper_parse_tuple(struct nf_conntrack_tuple *tuple,
 	if (!tb[NFCTH_TUPLE_L3PROTONUM] || !tb[NFCTH_TUPLE_L4PROTONUM])
 		return -EINVAL;
 
+	/* Not all fields are initialized so first zero the tuple */
+	memset(tuple, 0, sizeof(struct nf_conntrack_tuple));
+
 	tuple->src.l3num = ntohs(nla_get_be16(tb[NFCTH_TUPLE_L3PROTONUM]));
 	tuple->dst.protonum = nla_get_u8(tb[NFCTH_TUPLE_L4PROTONUM]);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: nf_tables: check for overflow of rule dlen field
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set Pablo Neira Ayuso
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

From: Patrick McHardy <kaber@trash.net>

[ upstream commit 9889840f5988ecfd43b00c9abb83c1804e21406b ]

Check that the space required for the expressions doesn't exceed the
size of the dlen field, which would lead to the iterators crashing.

Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 6fb532b..7baafd5 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1968,6 +1968,10 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
 			n++;
 		}
 	}
+	/* Check for overflow of dlen field */
+	err = -EFBIG;
+	if (size >= 1 << 12)
+		goto err1;
 
 	if (nla[NFTA_RULE_USERDATA])
 		ulen = nla_len(nla[NFTA_RULE_USERDATA]);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: check for overflow of rule dlen field Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: restore rule tracing via nfnetlink_log Pablo Neira Ayuso
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

[ upstream commit 749177ccc74f9c6d0f51bd78a15c652a2134aa11 ]

ip6tables extensions check for this flag to restrict match/target to a
given protocol. Without this flag set, SYNPROXY6 returns an error.

Cc: <stable@vger.kernel.org> # 3.14.x
Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nft_compat.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 213584c..65f3e2b 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -133,6 +133,9 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
@@ -344,6 +347,9 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: restore rule tracing via nfnetlink_log
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
                   ` (2 preceding siblings ...)
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: allow to change chain policy without hook if it exists Pablo Neira Ayuso
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

[ upstream commit 4017a7ee693d1cae6735c0dac21594a7c6416c4c ]

Since fab4085 ("netfilter: log: nf_log_packet() as real unified
interface"), the loginfo structure that is passed to nf_log_packet() is
used to explicitly indicate the logger type you want to use.

This is a problem for people tracing rules through nfnetlink_log since
packets are always routed to the NF_LOG_TYPE logger after the
aforementioned patch.

We can fix this by removing the trace loginfo structures, but that still
changes the log level from 4 to 5 for tracing messages and there may be
someone relying on this outthere. So let's just introduce a new
nf_log_trace() function that restores the former behaviour.

Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Reported-by: Markus Kötter <koetter@rrzn.uni-hannover.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/net/netfilter/nf_log.h  |   10 ++++++++++
 net/ipv4/netfilter/ip_tables.c  |    6 +++---
 net/ipv6/netfilter/ip6_tables.c |    6 +++---
 net/netfilter/nf_log.c          |   24 ++++++++++++++++++++++++
 net/netfilter/nf_tables_core.c  |    8 ++++----
 5 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
index 534e1f2..57639fc 100644
--- a/include/net/netfilter/nf_log.h
+++ b/include/net/netfilter/nf_log.h
@@ -79,6 +79,16 @@ void nf_log_packet(struct net *net,
 		   const struct nf_loginfo *li,
 		   const char *fmt, ...);
 
+__printf(8, 9)
+void nf_log_trace(struct net *net,
+		  u_int8_t pf,
+		  unsigned int hooknum,
+		  const struct sk_buff *skb,
+		  const struct net_device *in,
+		  const struct net_device *out,
+		  const struct nf_loginfo *li,
+		  const char *fmt, ...);
+
 struct nf_log_buf;
 
 struct nf_log_buf *nf_log_buf_open(void);
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 99e810f..cf5e82f 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -272,9 +272,9 @@ static void trace_packet(const struct sk_buff *skb,
 		    &chainname, &comment, &rulenum) != 0)
 			break;
 
-	nf_log_packet(net, AF_INET, hook, skb, in, out, &trace_loginfo,
-		      "TRACE: %s:%s:%s:%u ",
-		      tablename, chainname, comment, rulenum);
+	nf_log_trace(net, AF_INET, hook, skb, in, out, &trace_loginfo,
+		     "TRACE: %s:%s:%s:%u ",
+		     tablename, chainname, comment, rulenum);
 }
 #endif
 
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index e080fbb..bb00c6f 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -298,9 +298,9 @@ static void trace_packet(const struct sk_buff *skb,
 		    &chainname, &comment, &rulenum) != 0)
 			break;
 
-	nf_log_packet(net, AF_INET6, hook, skb, in, out, &trace_loginfo,
-		      "TRACE: %s:%s:%s:%u ",
-		      tablename, chainname, comment, rulenum);
+	nf_log_trace(net, AF_INET6, hook, skb, in, out, &trace_loginfo,
+		     "TRACE: %s:%s:%s:%u ",
+		     tablename, chainname, comment, rulenum);
 }
 #endif
 
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 0d8448f..675d12c 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -212,6 +212,30 @@ void nf_log_packet(struct net *net,
 }
 EXPORT_SYMBOL(nf_log_packet);
 
+void nf_log_trace(struct net *net,
+		  u_int8_t pf,
+		  unsigned int hooknum,
+		  const struct sk_buff *skb,
+		  const struct net_device *in,
+		  const struct net_device *out,
+		  const struct nf_loginfo *loginfo, const char *fmt, ...)
+{
+	va_list args;
+	char prefix[NF_LOG_PREFIXLEN];
+	const struct nf_logger *logger;
+
+	rcu_read_lock();
+	logger = rcu_dereference(net->nf.nf_loggers[pf]);
+	if (logger) {
+		va_start(args, fmt);
+		vsnprintf(prefix, sizeof(prefix), fmt, args);
+		va_end(args);
+		logger->logfn(net, pf, hooknum, skb, in, out, loginfo, prefix);
+	}
+	rcu_read_unlock();
+}
+EXPORT_SYMBOL(nf_log_trace);
+
 #define S_SIZE (1024 - (sizeof(unsigned int) + 1))
 
 struct nf_log_buf {
diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index 3b90eb2..2d298dc 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -94,10 +94,10 @@ static void nft_trace_packet(const struct nft_pktinfo *pkt,
 {
 	struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
 
-	nf_log_packet(net, pkt->xt.family, pkt->ops->hooknum, pkt->skb, pkt->in,
-		      pkt->out, &trace_loginfo, "TRACE: %s:%s:%s:%u ",
-		      chain->table->name, chain->name, comments[type],
-		      rulenum);
+	nf_log_trace(net, pkt->xt.family, pkt->ops->hooknum, pkt->skb, pkt->in,
+		     pkt->out, &trace_loginfo, "TRACE: %s:%s:%s:%u ",
+		     chain->table->name, chain->name, comments[type],
+		     rulenum);
 }
 
 unsigned int
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: nf_tables: allow to change chain policy without hook if it exists
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
                   ` (3 preceding siblings ...)
  2015-05-16 18:50 ` [PATCH -stable] netfilter: restore rule tracing via nfnetlink_log Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_rbtree: fix locking Pablo Neira Ayuso
  2015-05-20 12:12 ` [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Luis Henriques
  6 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

[ upstream commit d6b6cb1d3e6f78d55c2d4043d77d0d8def3f3b99 ]

If there's an existing base chain, we have to allow to change the
default policy without indicating the hook information.

However, if the chain doesn't exists, we have to enforce the presence of
the hook attribute.

Cc: <stable@vger.kernel.org> # 3.14.x
Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 6ab7779..ac1a952 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1225,7 +1225,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
 
 	if (nla[NFTA_CHAIN_POLICY]) {
 		if ((chain != NULL &&
-		    !(chain->flags & NFT_BASE_CHAIN)) ||
+		    !(chain->flags & NFT_BASE_CHAIN)))
+			return -EOPNOTSUPP;
+
+		if (chain == NULL &&
 		    nla[NFTA_CHAIN_HOOK] == NULL)
 			return -EOPNOTSUPP;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -stable] netfilter: nft_rbtree: fix locking
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
                   ` (4 preceding siblings ...)
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: allow to change chain policy without hook if it exists Pablo Neira Ayuso
@ 2015-05-16 18:50 ` Pablo Neira Ayuso
  2015-06-29 23:00   ` Greg KH
  2015-05-20 12:12 ` [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Luis Henriques
  6 siblings, 1 reply; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-05-16 18:50 UTC (permalink / raw)
  To: stable; +Cc: netfilter-devel

From: Patrick McHardy <kaber@trash.net>

[ upstream commit 16c45eda96038aae848b6cfd42e2bf4b5e80f365 ]

Fix a race condition and unnecessary locking:

* the root rb_node must only be accessed under the lock in nft_rbtree_lookup()
* the lock is not needed in lookup functions in netlink context

Cc: <stable@vger.kernel.org> # 3.18.x
Cc: <stable@vger.kernel.org> # 3.19.x
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nft_rbtree.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/netfilter/nft_rbtree.c b/net/netfilter/nft_rbtree.c
index 46214f2..2c75361 100644
--- a/net/netfilter/nft_rbtree.c
+++ b/net/netfilter/nft_rbtree.c
@@ -37,10 +37,11 @@ static bool nft_rbtree_lookup(const struct nft_set *set,
 {
 	const struct nft_rbtree *priv = nft_set_priv(set);
 	const struct nft_rbtree_elem *rbe, *interval = NULL;
-	const struct rb_node *parent = priv->root.rb_node;
+	const struct rb_node *parent;
 	int d;
 
 	spin_lock_bh(&nft_rbtree_lock);
+	parent = priv->root.rb_node;
 	while (parent != NULL) {
 		rbe = rb_entry(parent, struct nft_rbtree_elem, node);
 
@@ -158,7 +159,6 @@ static int nft_rbtree_get(const struct nft_set *set, struct nft_set_elem *elem)
 	struct nft_rbtree_elem *rbe;
 	int d;
 
-	spin_lock_bh(&nft_rbtree_lock);
 	while (parent != NULL) {
 		rbe = rb_entry(parent, struct nft_rbtree_elem, node);
 
@@ -173,11 +173,9 @@ static int nft_rbtree_get(const struct nft_set *set, struct nft_set_elem *elem)
 			    !(rbe->flags & NFT_SET_ELEM_INTERVAL_END))
 				nft_data_copy(&elem->data, rbe->data);
 			elem->flags = rbe->flags;
-			spin_unlock_bh(&nft_rbtree_lock);
 			return 0;
 		}
 	}
-	spin_unlock_bh(&nft_rbtree_lock);
 	return -ENOENT;
 }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple()
  2015-05-16 18:50 ` [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Pablo Neira Ayuso
@ 2015-05-19 11:31   ` Jiri Slaby
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2015-05-19 11:31 UTC (permalink / raw)
  To: Pablo Neira Ayuso, stable; +Cc: netfilter-devel

On 05/16/2015, 08:50 PM, Pablo Neira Ayuso wrote:
> From: Ian Wilson <iwilson@brocade.com>
> 
> [ upstream commit 78146572b9cd20452da47951812f35b1ad4906be ]
> 
> nfnl_cthelper_parse_tuple() is called from nfnl_cthelper_new(),
> nfnl_cthelper_get() and nfnl_cthelper_del().  In each case they pass
> a pointer to an nf_conntrack_tuple data structure local variable:
> 
>     struct nf_conntrack_tuple tuple;
>     ...
>     ret = nfnl_cthelper_parse_tuple(&tuple, tb[NFCTH_TUPLE]);
> 
> The problem is that this local variable is not initialized, and
> nfnl_cthelper_parse_tuple() only initializes two fields: src.l3num and
> dst.protonum.  This leaves all other fields with undefined values
> based on whatever is on the stack:
> 
>     tuple->src.l3num = ntohs(nla_get_be16(tb[NFCTH_TUPLE_L3PROTONUM]));
>     tuple->dst.protonum = nla_get_u8(tb[NFCTH_TUPLE_L4PROTONUM]);
> 
> The symptom observed was that when the rpc and tns helpers were added
> then traffic to port 1536 was being sent to user-space.
> 
> Cc: <stable@vger.kernel.org> # 3.10.x
> Cc: <stable@vger.kernel.org> # 3.12.x

Applied only this one to 3.12 (others are not marked as such). Thanks.

> Cc: <stable@vger.kernel.org> # 3.14.x
> Cc: <stable@vger.kernel.org> # 3.18.x
> Cc: <stable@vger.kernel.org> # 3.19.x
> Signed-off-by: Ian Wilson <iwilson@brocade.com>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  net/netfilter/nfnetlink_cthelper.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
> index a5599fc..54330fb 100644
> --- a/net/netfilter/nfnetlink_cthelper.c
> +++ b/net/netfilter/nfnetlink_cthelper.c
> @@ -77,6 +77,9 @@ nfnl_cthelper_parse_tuple(struct nf_conntrack_tuple *tuple,
>  	if (!tb[NFCTH_TUPLE_L3PROTONUM] || !tb[NFCTH_TUPLE_L4PROTONUM])
>  		return -EINVAL;
>  
> +	/* Not all fields are initialized so first zero the tuple */
> +	memset(tuple, 0, sizeof(struct nf_conntrack_tuple));
> +
>  	tuple->src.l3num = ntohs(nla_get_be16(tb[NFCTH_TUPLE_L3PROTONUM]));
>  	tuple->dst.protonum = nla_get_u8(tb[NFCTH_TUPLE_L4PROTONUM]);
>  
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement
  2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
                   ` (5 preceding siblings ...)
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_rbtree: fix locking Pablo Neira Ayuso
@ 2015-05-20 12:12 ` Luis Henriques
  6 siblings, 0 replies; 11+ messages in thread
From: Luis Henriques @ 2015-05-20 12:12 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: stable, netfilter-devel

On Sat, May 16, 2015 at 08:50:45PM +0200, Pablo Neira Ayuso wrote:
> [ upstream commit 59900e0a019e7c2bdb7809a03ed5742d311b15b3 ]
>

Thank you, Pablo.

I've took a look at these 7 patches, and most of them seem to be
applicable to the 3.16 kernel as well.  I'm queuing the following set
for the next 3.16 release:

 59900e0a019e ("netfilter: nf_tables: fix error handling of rule replacement")
 78146572b9cd ("netfilter: Zero the tuple in nfnl_cthelper_parse_tuple()")
 9889840f5988 ("netfilter: nf_tables: check for overflow of rule dlen field")
 749177ccc74f ("netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set")
 d6b6cb1d3e6f ("netfilter: nf_tables: allow to change chain policy without hook if it exists")
 16c45eda9603 ("netfilter: nft_rbtree: fix locking")

So, from your initial set, I've dropped only 4017a7ee693d ("netfilter:
restore rule tracing via nfnetlink_log").

Cheers,
--
Luís

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -stable] netfilter: nft_rbtree: fix locking
  2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_rbtree: fix locking Pablo Neira Ayuso
@ 2015-06-29 23:00   ` Greg KH
  2015-07-01 11:38     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2015-06-29 23:00 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: stable, netfilter-devel

On Sat, May 16, 2015 at 08:50:51PM +0200, Pablo Neira Ayuso wrote:
> From: Patrick McHardy <kaber@trash.net>
> 
> [ upstream commit 16c45eda96038aae848b6cfd42e2bf4b5e80f365 ]
> 
> Fix a race condition and unnecessary locking:
> 
> * the root rb_node must only be accessed under the lock in nft_rbtree_lookup()
> * the lock is not needed in lookup functions in netlink context
> 
> Cc: <stable@vger.kernel.org> # 3.18.x
> Cc: <stable@vger.kernel.org> # 3.19.x
> Signed-off-by: Patrick McHardy <kaber@trash.net>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  net/netfilter/nft_rbtree.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Also 4.0, right?  This showed up in Linus's tree in 4.1-rc1.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -stable] netfilter: nft_rbtree: fix locking
  2015-06-29 23:00   ` Greg KH
@ 2015-07-01 11:38     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 11+ messages in thread
From: Pablo Neira Ayuso @ 2015-07-01 11:38 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, netfilter-devel

On Mon, Jun 29, 2015 at 04:00:53PM -0700, Greg KH wrote:
> On Sat, May 16, 2015 at 08:50:51PM +0200, Pablo Neira Ayuso wrote:
> > From: Patrick McHardy <kaber@trash.net>
> > 
> > [ upstream commit 16c45eda96038aae848b6cfd42e2bf4b5e80f365 ]
> > 
> > Fix a race condition and unnecessary locking:
> > 
> > * the root rb_node must only be accessed under the lock in nft_rbtree_lookup()
> > * the lock is not needed in lookup functions in netlink context
> > 
> > Cc: <stable@vger.kernel.org> # 3.18.x
> > Cc: <stable@vger.kernel.org> # 3.19.x
> > Signed-off-by: Patrick McHardy <kaber@trash.net>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> >  net/netfilter/nft_rbtree.c |    6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> Also 4.0, right?  This showed up in Linus's tree in 4.1-rc1.

Yes please. thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-07-01 11:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-16 18:50 [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Pablo Neira Ayuso
2015-05-16 18:50 ` [PATCH -stable] netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() Pablo Neira Ayuso
2015-05-19 11:31   ` Jiri Slaby
2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: check for overflow of rule dlen field Pablo Neira Ayuso
2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set Pablo Neira Ayuso
2015-05-16 18:50 ` [PATCH -stable] netfilter: restore rule tracing via nfnetlink_log Pablo Neira Ayuso
2015-05-16 18:50 ` [PATCH -stable] netfilter: nf_tables: allow to change chain policy without hook if it exists Pablo Neira Ayuso
2015-05-16 18:50 ` [PATCH -stable] netfilter: nft_rbtree: fix locking Pablo Neira Ayuso
2015-06-29 23:00   ` Greg KH
2015-07-01 11:38     ` Pablo Neira Ayuso
2015-05-20 12:12 ` [PATCH -stable] netfilter: nf_tables: fix error handling of rule replacement Luis Henriques

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).