Skip to contentSkip to conversation

netfilter: nftables: Do not run chains in the wrong network namespace

PATCH Applied Eric W. Biederman 3 participants 3 messages Jun 19, 2015 – Jun 23, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nftables: Do not run chains in the wrong network namespace

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.

---
 net/netfilter/nf_tables_core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_core.c +6 -1
index f153b07073af..f77bad46ac68 100644
@@ -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);
Signature · 4 lines
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric W. Biederman

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.

@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

maintainer Applied
#2 lore raw
In reply to Eric W. Biederman

From: [email protected] (Eric W. Biederman)
Date: Fri, 19 Jun 2015 10:41:21 -0500

Quoted 10 lines

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.

Applied.