netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace
@ 2015-06-19 15:41 Eric W. Biederman
  2015-06-19 17:21 ` Pablo Neira Ayuso
  2015-06-23 13:23 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Eric W. Biederman @ 2015-06-19 15:41 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, netfilter-devel, Pablo Neira Ayuso, Patrick McHardy


Currenlty nf_tables chains added in one network namespace are being
run in all network namespace.  The issues are myriad with the simplest
being an unprivileged user can cause any network packets to be dropped.

Address this by simply not running nf_tables chains in the wrong
network namespace.

Cc: stable@vger.kernel.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 net/netfilter/nf_tables_core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index f153b07073af..f77bad46ac68 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -114,7 +114,8 @@ unsigned int
 nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops)
 {
 	const struct nft_chain *chain = ops->priv, *basechain = chain;
-	const struct net *net = read_pnet(&nft_base_chain(basechain)->pnet);
+	const struct net *chain_net = read_pnet(&nft_base_chain(basechain)->pnet);
+	const struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
 	const struct nft_rule *rule;
 	const struct nft_expr *expr, *last;
 	struct nft_regs regs;
@@ -124,6 +125,10 @@ nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops)
 	int rulenum;
 	unsigned int gencursor = nft_genmask_cur(net);
 
+	/* Ignore chains that are not for the current network namespace */
+	if (!net_eq(net, chain_net))
+		return NF_ACCEPT;
+
 do_chain:
 	rulenum = 0;
 	rule = list_entry(&chain->rules, struct nft_rule, list);
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in

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

* Re: [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace
  2015-06-19 15:41 [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace Eric W. Biederman
@ 2015-06-19 17:21 ` Pablo Neira Ayuso
  2015-06-23 13:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-19 17:21 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: David Miller, netdev, netfilter-devel, Patrick McHardy

On Fri, Jun 19, 2015 at 10:41:21AM -0500, Eric W. Biederman wrote:
> 
> Currenlty nf_tables chains added in one network namespace are being
> run in all network namespace.  The issues are myriad with the simplest
> being an unprivileged user can cause any network packets to be dropped.
> 
> Address this by simply not running nf_tables chains in the wrong
> network namespace.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>

@David: Patrick sent a similar patch to address this, if you can get
this into the net tree, I'll make sure this propagates to -stable.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in

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

* Re: [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace
  2015-06-19 15:41 [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace Eric W. Biederman
  2015-06-19 17:21 ` Pablo Neira Ayuso
@ 2015-06-23 13:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-06-23 13:23 UTC (permalink / raw)
  To: ebiederm; +Cc: netdev, netfilter-devel, pablo, kaber

From: ebiederm@xmission.com (Eric W. Biederman)
Date: Fri, 19 Jun 2015 10:41:21 -0500

> 
> Currenlty nf_tables chains added in one network namespace are being
> run in all network namespace.  The issues are myriad with the simplest
> being an unprivileged user can cause any network packets to be dropped.
> 
> Address this by simply not running nf_tables chains in the wrong
> network namespace.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Applied.

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

end of thread, other threads:[~2015-06-23 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-19 15:41 [PATCH net] netfilter: nftables: Do not run chains in the wrong network namespace Eric W. Biederman
2015-06-19 17:21 ` Pablo Neira Ayuso
2015-06-23 13:23 ` David Miller

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