Skip to contentSkip to conversation

Netfilter fixes for net

PATCH In review Pablo Neira Ayuso 2 participants 8 messages Feb 27, 2017

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

cover Netfilter fixes for net

Hi David,

The following patchset contains netfilter fixes for you net tree, they are:

1) Missing ct zone size in the nft_ct initialization path, patch from Florian Westphal.

2) Two patches for netfilter uapi headers, one to remove unnecessary sysctl.h inclusion and another to fix compilation of xt_hashlimit.h in userspace, from Dmitry V. Levin.

3) Patch to fix a sloppy change in nf_ct_expect that incorrectly simplified nf_ct_expect_related_report() in the previous nf-next batch. This also includes another patch for __nf_ct_expect_check() to report success by returning 0 to keep it consistent with other existing functions. From Jarno Rajahalme.

4) The ->walk() iterator of the new bitmap set type goes over the real bitmap size, this results in incorrect dumps when NFTA_SET_USERDATA is used.

You can pull these changes from:

git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git

Thanks!

----------------------------------------------------------------

The following changes since commit 9c4713701c01e4cef6e2315c2818abc919ffb0de:

bpf: Fix bpf_xdp_event_output (2017-02-23 13:53:42 -0500)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD

for you to fetch changes up to 13aa5a8f498dacd5f1a8e35be72af47e630fb8c6:

netfilter: nft_set_bitmap: incorrect bitmap size (2017-02-26 21:00:19 +0100)

----------------------------------------------------------------
Dmitry V. Levin (2):
uapi: stop including linux/sysctl.h in uapi/linux/netfilter.h
uapi: fix linux/netfilter/xt_hashlimit.h userspace compilation error

Florian Westphal (1):
netfilter: nft_ct: fix random validation errors for zone set support

Jarno Rajahalme (2):
netfilter: nf_ct_expect: nf_ct_expect_related_report(): Return zero on success.
netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value.

Pablo Neira Ayuso (1):
netfilter: nft_set_bitmap: incorrect bitmap size

 include/uapi/linux/netfilter.h              | 1 -
 include/uapi/linux/netfilter/xt_hashlimit.h | 1 +
 net/netfilter/nf_conntrack_expect.c         | 6 +++---
 net/netfilter/nft_ct.c                      | 1 +
 net/netfilter/nft_set_bitmap.c              | 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)
author maintainer
#1 lore raw

PATCH 1/6 netfilter: nft_ct: fix random validation errors for zone set support

From: Florian Westphal <[email protected]>

Dan reports:
net/netfilter/nft_ct.c:549 nft_ct_set_init()
error: uninitialized symbol 'len'.

Fixes edee4f1e924582 ("netfilter: nft_ct: add zone id set support")
---
 net/netfilter/nft_ct.c | 1 +
 1 file changed, 1 insertion(+)
net/netfilter/nft_ct.c +1 -0
index c6b8022c0e47..bf548a7a71ec 100644
@@ -528,6 +528,7 @@ static int nft_ct_set_init(const struct nft_ctx *ctx,
 		if (!nft_ct_tmpl_alloc_pcpu())
 			return -ENOMEM;
 		nft_ct_pcpu_template_refcnt++;
+		len = sizeof(u16);
 		break;
 #endif
 	default:
Signature · 1 line
2.1.4
author maintainer
#2 lore raw

PATCH 2/6 uapi: stop including linux/sysctl.h in uapi/linux/netfilter.h

In reply to Pablo Neira Ayuso

From: "Dmitry V. Levin" <[email protected]>

linux/netfilter.h is the last uapi header file that includes linux/sysctl.h but it does not depend on definitions provided by this essentially dead header file.

---
 include/uapi/linux/netfilter.h | 1 -
 1 file changed, 1 deletion(-)
include/uapi/linux/netfilter.h +0 -1
index 7550e9176a54..c111a91adcc0 100644
@@ -3,7 +3,6 @@
 
 #include <linux/types.h>
 #include <linux/compiler.h>
-#include <linux/sysctl.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 
Signature · 1 line
2.1.4
author maintainer
#3 lore raw

PATCH 3/6 uapi: fix linux/netfilter/xt_hashlimit.h userspace compilation error

In reply to Pablo Neira Ayuso

From: "Dmitry V. Levin" <[email protected]>

Include <linux/limits.h> like some of uapi/linux/netfilter/xt_*.h headers do to fix the following linux/netfilter/xt_hashlimit.h userspace compilation error:

/usr/include/linux/netfilter/xt_hashlimit.h:90:12: error: 'NAME_MAX' undeclared here (not in a function)
char name[NAME_MAX];

---
 include/uapi/linux/netfilter/xt_hashlimit.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/netfilter/xt_hashlimit.h +1 -0
index 3efc0ca18345..79da349f1060 100644
@@ -2,6 +2,7 @@
 #define _UAPI_XT_HASHLIMIT_H
 
 #include <linux/types.h>
+#include <linux/limits.h>
 #include <linux/if.h>
 
 /* timings are in milliseconds. */
Signature · 1 line
2.1.4
author maintainer
#4 lore raw

PATCH 4/6 netfilter: nf_ct_expect: nf_ct_expect_related_report(): Return zero on success.

In reply to Pablo Neira Ayuso

From: Jarno Rajahalme <[email protected]>

Commit 4dee62b1b9b4 ("netfilter: nf_ct_expect: nf_ct_expect_insert() returns void") inadvertently changed the successful return value of nf_ct_expect_related_report() from 0 to 1, which caused openvswitch conntrack integration fail in FTP test cases.

Fix this by always returning zero on the success code path.

Fixes 4dee62b1b9b4 ("netfilter: nf_ct_expect: nf_ct_expect_insert() returns void")
---
 net/netfilter/nf_conntrack_expect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_expect.c +1 -1
index e19a69787d99..d6ace69d57dc 100644
@@ -467,7 +467,7 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
 
 	spin_unlock_bh(&nf_conntrack_expect_lock);
 	nf_ct_expect_event_report(IPEXP_NEW, expect, portid, report);
-	return ret;
+	return 0;
 out:
 	spin_unlock_bh(&nf_conntrack_expect_lock);
 	return ret;
Signature · 1 line
2.1.4
author maintainer
#5 lore raw

PATCH 5/6 netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value.

In reply to Pablo Neira Ayuso

From: Jarno Rajahalme <[email protected]>

Commit 4dee62b1b9b4 ("netfilter: nf_ct_expect: nf_ct_expect_insert() returns void") inadvertently changed the successful return value of nf_ct_expect_related_report() from 0 to 1 due to __nf_ct_expect_check() returning 1 on success. Prevent this regression in the future by changing the return value of __nf_ct_expect_check() to 0 on success.

---
 net/netfilter/nf_conntrack_expect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_expect.c +2 -2
index d6ace69d57dc..4b2e1fb28bb4 100644
@@ -410,7 +410,7 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect)
 	struct net *net = nf_ct_exp_net(expect);
 	struct hlist_node *next;
 	unsigned int h;
-	int ret = 1;
+	int ret = 0;
 
 	if (!master_help) {
 		ret = -ESHUTDOWN;
@@ -460,7 +460,7 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
 
 	spin_lock_bh(&nf_conntrack_expect_lock);
 	ret = __nf_ct_expect_check(expect);
-	if (ret <= 0)
+	if (ret < 0)
 		goto out;
 
 	nf_ct_expect_insert(expect);
Signature · 1 line
2.1.4
author maintainer
#6 lore raw

PATCH 6/6 netfilter: nft_set_bitmap: incorrect bitmap size

In reply to Pablo Neira Ayuso

priv->bitmap_size stores the real bitmap size, instead of the full struct nft_bitmap object.

Fixes 665153ff5752 ("netfilter: nf_tables: add bitmap set type")
---
 net/netfilter/nft_set_bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_set_bitmap.c +1 -1
index 97f9649bcc7e..152d226552c1 100644
@@ -258,7 +258,7 @@ static int nft_bitmap_init(const struct nft_set *set,
 {
 	struct nft_bitmap *priv = nft_set_priv(set);
 
-	priv->bitmap_size = nft_bitmap_total_size(set->klen);
+	priv->bitmap_size = nft_bitmap_size(set->klen);
 
 	return 0;
 }
Signature · 1 line
2.1.4
maintainer
#7 lore raw
In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso <[email protected]>
Date: Mon, 27 Feb 2017 12:35:36 +0100

Quoted 16 lines

The following patchset contains netfilter fixes for you net tree, they are:

1) Missing ct zone size in the nft_ct initialization path, patch from Florian Westphal.

2) Two patches for netfilter uapi headers, one to remove unnecessary sysctl.h inclusion and another to fix compilation of xt_hashlimit.h in userspace, from Dmitry V. Levin.

3) Patch to fix a sloppy change in nf_ct_expect that incorrectly simplified nf_ct_expect_related_report() in the previous nf-next batch. This also includes another patch for __nf_ct_expect_check() to report success by returning 0 to keep it consistent with other existing functions. From Jarno Rajahalme.

Quoted 7 lines

4) The ->walk() iterator of the new bitmap set type goes over the real bitmap size, this results in incorrect dumps when NFTA_SET_USERDATA is used.

You can pull these changes from:

git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git

Pulled, thanks Pablo.