[PATCH] iptables: extensions: Remove unnecessary parenthesis.

2017-03-29 Thread Arushi Singhal
Removed parenthesis on the right hand side of assignment, as they are not required. The following coccinelle script was used to fix this issue: @@ local idexpression id; expression e; @@ id = -( e -) Signed-off-by: Arushi Singhal --- extensions/libebt_mark.c | 8 extensions/libxt_str

[PATCH] iptables: extensions: Add/Remove unnecessary spaces.

2017-03-29 Thread Arushi Singhal
This patch add or remove unnecessary spaces as reported by checkpatch.pl. Signed-off-by: Arushi Singhal --- extensions/libebt_802_3.c | 4 ++-- extensions/libip6t_dst.c| 8 extensions/libip6t_hbh.c| 8 extensions/libip6t_ipv6header.c | 2 +- 4 files change

Re: [PATCH nf V2] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Liping Zhang
Hi Pablo, 2017-03-29 21:00 GMT+08:00 Liping Zhang : > From: Liping Zhang > > cthelpers added via nfnetlink may have the same tuple, i.e. except for > the l3proto and l4proto, other fields are all zero. So even with the > different names, we will also fail to add them: > # nfct helper add ssdp i

[PATCH] iptables: extensions: Add blank line after declarations.

2017-03-29 Thread Arushi Singhal
Add blank line after declaration as reported by checkpatch.pl. Signed-off-by: Arushi Singhal --- extensions/libip6t_mh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/libip6t_mh.c b/extensions/libip6t_mh.c index f4c0fd9..ee17182 100644 --- a/extensions/libip6t_mh.c +++ b/extensi

[PATCH] iptables: extensions: Remove assignment in if condition.

2017-03-29 Thread Arushi Singhal
Remove assignments in if condition as reported by checkpatch.pl. Signed-off-by: Arushi Singhal --- extensions/libebt_ip.c | 11 ++- extensions/libip6t_ipv6header.c | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/extensions/libebt_ip.c b/extensions/libe

[PATCH] iptables: extensions: Add space around operators

2017-03-29 Thread Arushi Singhal
Add spaces around operator and remove trailing whitespaces. Signed-off-by: Arushi Singhal --- extensions/dscp_helper.c| 2 +- extensions/libarpt_mangle.c | 2 +- extensions/libip6t_ah.c | 2 +- extensions/libip6t_dst.c| 6 +++--- extensions/libip6t_frag.c | 2 +- extensions/li

Re: [PATCH 0/8] Netfilter fixes for net

2017-03-29 Thread David Miller
From: Pablo Neira Ayuso Date: Wed, 29 Mar 2017 14:14:02 +0200 > Hi David, > > The following patchset contains a rather large update with Netfilter > fixes, specifically targeted to incorrect RCU usage in several spots and > the userspace conntrack helper infrastructure (nfnetlink_cthelper), > mo

[PATCH 2/2] iptables: Remove unnecessary braces.

2017-03-29 Thread Varsha Rao
Remove braces which are not required, to fix the check patch issue. The following coccinelle script was used to fix this issue. @@ expression e; expression e1; @@ if(e) -{ e1; -} Signed-off-by: Varsha Rao --- iptables/iptables-standalone.c | 3 +-- iptables/iptables.c| 3 +-- iptab

[PATCH 1/2] iptables: Remove explicit static variables initalization.

2017-03-29 Thread Varsha Rao
Static variables are initialized to zero by default, so remove explicit initalization. This patch fixes the checkpatch issue. Signed-off-by: Varsha Rao --- iptables/ip6tables-restore.c | 2 +- iptables/ip6tables-save.c| 2 +- iptables/iptables-restore.c | 2 +- iptables/iptables-save.c

[PATCH 0/2] iptables: Fix multiple checkpatch issues.

2017-03-29 Thread Varsha Rao
This patchset fixes multiple checkpatch issues. Varsha Rao (2): iptables: Remove explicit static variables initalization. iptables: Remove unnecessary braces. iptables/ip6tables-restore.c | 2 +- iptables/ip6tables-save.c | 2 +- iptables/iptables-restore.c| 2 +- iptables/ipta

[PATCH v2] net: netfilter: remove unused variable

2017-03-29 Thread Arushi Singhal
This patch uses the following coccinelle script to remove a variable that was simply used to store the return value of a function call before returning it: @@ identifier len,f; @@ -int len; ... when != len when strict -len = +return f(...); -return len; Signed-off-by: Arushi Singha

Re: [Outreachy kernel] [PATCH] net: netfilter: remove unused variable

2017-03-29 Thread Julia Lawall
On Wed, 29 Mar 2017, Arushi Singhal wrote: > This patch uses the following coccinelle script to remove > a variable that was simply used to store the return > value of a function call before returning it: > > @@ > identifier len,f; > @@ > > -int len; > ... when != len > when strict > -len

[PATCH] net: netfilter: remove unused variable

2017-03-29 Thread Arushi Singhal
This patch uses the following coccinelle script to remove a variable that was simply used to store the return value of a function call before returning it: @@ identifier len,f; @@ -int len; ... when != len when strict -len = +return f(...); -return len; Signed-off-by: Arushi Singha

[PATCH nf V2] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Liping Zhang
From: Liping Zhang cthelpers added via nfnetlink may have the same tuple, i.e. except for the l3proto and l4proto, other fields are all zero. So even with the different names, we will also fail to add them: # nfct helper add ssdp inet udp # nfct helper add tftp inet udp nfct v1.4.3: netlink

RE: [PATCH nf v4 2/2] netfilter: helper: Fix possible panic caused by invoking expectfn unloaded

2017-03-29 Thread Gao Feng
Hi Pablo, > -Original Message- > From: netfilter-devel-ow...@vger.kernel.org > [mailto:netfilter-devel-ow...@vger.kernel.org] On Behalf Of Pablo Neira Ayuso > Sent: Wednesday, March 29, 2017 5:54 PM > To: gfree.w...@foxmail.com > Cc: netfilter-devel@vger.kernel.org; Gao Feng > Subject: Re

[PATCH 8/8] netfilter: nfnetlink_queue: fix secctx memory leak

2017-03-29 Thread Pablo Neira Ayuso
From: Liping Zhang We must call security_release_secctx to free the memory returned by security_secid_to_secctx, otherwise memory may be leaked forever. Fixes: ef493bd930ae ("netfilter: nfnetlink_queue: add security context information") Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira A

[PATCH 7/8] netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register

2017-03-29 Thread Pablo Neira Ayuso
From: Gao Feng In the commit 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper"), the snmp_helper is replaced by nf_nat_snmp_hook. So the snmp_helper is never registered. But it still tries to unregister the snmp_helper, it could cause the panic. Now remove the useless snmp_helper

[PATCH 6/8] netfilter: nf_ct_ext: fix possible panic after nf_ct_extend_unregister

2017-03-29 Thread Pablo Neira Ayuso
From: Liping Zhang If one cpu is doing nf_ct_extend_unregister while another cpu is doing __nf_ct_ext_add_length, then we may hit BUG_ON(t == NULL). Moreover, there's no synchronize_rcu invocation after set nf_ct_ext_types[id] to NULL, so it's possible that we may access invalid pointer. But act

[PATCH 4/8] netfilter: invoke synchronize_rcu after set the _hook_ to NULL

2017-03-29 Thread Pablo Neira Ayuso
From: Liping Zhang Otherwise, another CPU may access the invalid pointer. For example: CPU0CPU1 - rcu_read_lock(); - pfunc = _hook_; _hook_ = NULL; - mod unload - - pfunc(); // invalid, panic

[PATCH 5/8] netfilter: nfnl_cthelper: fix a race when walk the nf_ct_helper_hash table

2017-03-29 Thread Pablo Neira Ayuso
From: Liping Zhang The nf_ct_helper_hash table is protected by nf_ct_helper_mutex, while nfct_helper operation is protected by nfnl_lock(NFNL_SUBSYS_CTHELPER). So it's possible that one CPU is walking the nf_ct_helper_hash for cthelper add/get/del, another cpu is doing nf_conntrack_helpers_unregi

[PATCH 1/8] netfilter: nfnl_cthelper: fix incorrect helper->expect_class_max

2017-03-29 Thread Pablo Neira Ayuso
From: Liping Zhang The helper->expect_class_max must be set to the total number of expect_policy minus 1, since we will use the statement "if (class > helper->expect_class_max)" to validate the CTA_EXPECT_CLASS attr in ctnetlink_alloc_expect. So for compatibility, set the helper->expect_class_ma

[PATCH 3/8] netfilter: nfnl_cthelper: Fix memory leak

2017-03-29 Thread Pablo Neira Ayuso
From: Jeffy Chen We have memory leaks of nf_conntrack_helper & expect_policy. Signed-off-by: Jeffy Chen Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nfnetlink_cthelper.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nfnetlink_cthelper.c

[PATCH 2/8] netfilter: nfnl_cthelper: fix runtime expectation policy updates

2017-03-29 Thread Pablo Neira Ayuso
We only allow runtime updates of expectation policies for timeout and maximum number of expectations, otherwise reject the update. Signed-off-by: Pablo Neira Ayuso Acked-by: Liping Zhang --- net/netfilter/nfnetlink_cthelper.c | 86 +- 1 file changed, 84 inser

[PATCH 0/8] Netfilter fixes for net

2017-03-29 Thread Pablo Neira Ayuso
Hi David, The following patchset contains a rather large update with Netfilter fixes, specifically targeted to incorrect RCU usage in several spots and the userspace conntrack helper infrastructure (nfnetlink_cthelper), more specifically they are: 1) expect_class_max is incorrect set via cthelper

Re: [PATCH nf] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Pablo Neira Ayuso
On Wed, Mar 29, 2017 at 07:05:10PM +0800, Liping Zhang wrote: > Hi Pablo, > > 2017-03-29 18:41 GMT+08:00 Pablo Neira Ayuso : > [...] > > Wait. > > > > Just a comestic change, would this look better if we just do: > > > > hlist_for_each_entry(cur, &nf_ct_helper_hash[h], hnode) { > >

Re: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock when get expectfn

2017-03-29 Thread Pablo Neira Ayuso
On Wed, Mar 29, 2017 at 06:50:46PM +0800, Gao Feng wrote: > Hi Pablo, > > > -Original Message- > > From: Pablo Neira Ayuso [mailto:pa...@netfilter.org] > > Sent: Wednesday, March 29, 2017 6:44 PM > > To: Gao Feng > > Cc: netfilter-devel@vger.kernel.org; 'Gao Feng' > > Subject: Re: [PATCH

Re: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock when get expectfn

2017-03-29 Thread Pablo Neira Ayuso
On Wed, Mar 29, 2017 at 06:29:10PM +0800, Gao Feng wrote: > Hi Pablo, > > > -Original Message- > > From: Pablo Neira Ayuso [mailto:pa...@netfilter.org] > > Sent: Wednesday, March 29, 2017 6:08 PM > > To: gfree.w...@foxmail.com > > Cc: netfilter-devel@vger.kernel.org; Gao Feng > > Subject:

[PATCH nf v3 1/1] netfilter: helper: Add the rcu lock when call __nf_conntrack_helper_find

2017-03-29 Thread gfree . wind
From: Gao Feng When invoke __nf_conntrack_helper_find, it needs the rcu lock to protect the helper module which would not be unloaded. Now there are two caller nf_conntrack_helper_try_module_get and ctnetlink_create_expect which don't hold rcu lock. And the other callers left like ctnetlink_chan

Re: [PATCH nf] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Liping Zhang
Hi Pablo, 2017-03-29 18:41 GMT+08:00 Pablo Neira Ayuso : [...] > Wait. > > Just a comestic change, would this look better if we just do: > > hlist_for_each_entry(cur, &nf_ct_helper_hash[h], hnode) { > if (!strcmp(h->name, name) && > (h->tuple.src.l3num

RE: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock when get expectfn

2017-03-29 Thread Gao Feng
Hi Pablo, > -Original Message- > From: Pablo Neira Ayuso [mailto:pa...@netfilter.org] > Sent: Wednesday, March 29, 2017 6:44 PM > To: Gao Feng > Cc: netfilter-devel@vger.kernel.org; 'Gao Feng' > Subject: Re: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock > when get exp

Re: [PATCH nf] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Pablo Neira Ayuso
On Sat, Mar 25, 2017 at 09:03:23PM +0800, Liping Zhang wrote: > From: Liping Zhang > > cthelpers added via nfnetlink may have the same tuple, i.e. except for > the l3proto and l4proto, other fields are all zero. So even with the > different names, we will also fail to add them: > # nfct helper

Re: [PATCH nf] netfilter: nf_ct_helper: permit cthelpers with different names via nfnetlink

2017-03-29 Thread Pablo Neira Ayuso
On Sat, Mar 25, 2017 at 09:03:23PM +0800, Liping Zhang wrote: > From: Liping Zhang > > cthelpers added via nfnetlink may have the same tuple, i.e. except for > the l3proto and l4proto, other fields are all zero. So even with the > different names, we will also fail to add them: > # nfct helper

Re: [PATCH nf] netfilter: nfnetlink_queue: fix secctx memory leak

2017-03-29 Thread Pablo Neira Ayuso
On Tue, Mar 28, 2017 at 10:59:25PM +0800, Liping Zhang wrote: > From: Liping Zhang > > We must call security_release_secctx to free the memory returned by > security_secid_to_secctx, otherwise memory may be leaked forever. Applied, thanks. -- To unsubscribe from this list: send the line "unsubsc

RE: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock when get expectfn

2017-03-29 Thread Gao Feng
Hi Pablo, > -Original Message- > From: Pablo Neira Ayuso [mailto:pa...@netfilter.org] > Sent: Wednesday, March 29, 2017 6:08 PM > To: gfree.w...@foxmail.com > Cc: netfilter-devel@vger.kernel.org; Gao Feng > Subject: Re: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock > w

[PATCH] net: ipv6: Removed unnecessary parenthesis

2017-03-29 Thread Arushi Singhal
Removed parentheses on the right hand side of assignment, as they are not required. The following coccinelle script was used to fix this issue: @@ local idexpression id; expression e; @@ id = -( e -) Signed-off-by: Arushi Singhal --- net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++-- 1 file cha

[PATCH] net: netfilter: Replace explicit NULL comparison with ! operator

2017-03-29 Thread Arushi Singhal
Replace explicit NULL comparison with ! operator to simplify code. Signed-off-by: Arushi Singhal --- net/netfilter/ipvs/ip_vs_ctl.c | 8 ++--- net/netfilter/ipvs/ip_vs_proto.c | 8 ++--- net/netfilter/nf_conntrack_broadcast.c | 2 +- net/netfilter/nf_conntrack_core.c | 2 +

Re: [PATCH nft] src: allow update of net base w. meta l4proto icmpv6

2017-03-29 Thread Pablo Neira Ayuso
On Fri, Mar 24, 2017 at 01:21:12PM +0100, Florian Westphal wrote: > Pablo Neira Ayuso wrote: > > We can just use NFT_META_L4PROTO all the time, so we use it from IPv4 > > too, right? > > Right, we can indeed do that and change ip as well. BTW, I think this problem may be the root cause for this

Re: [PATCH nf-next v2 1/1] netfilter: helper: Remove useless rcu lock when get expectfn

2017-03-29 Thread Pablo Neira Ayuso
On Wed, Mar 22, 2017 at 10:15:02AM +0800, gfree.w...@foxmail.com wrote: > From: Gao Feng > > Because these two functions return the nf_ct_helper_expectfn pointer > which should be protected by rcu lock. So it should makes sure the > caller should hold the rcu lock, not inside these functions. >

[PATCH] net: netfilterL: Fix line over 80 characters.

2017-03-29 Thread Arushi Singhal
fix the line over 80 characters as reported by checkpatch.pl Signed-off-by: Arushi Singhal --- net/ipv6/netfilter/ip6_tables.c| 6 -- net/ipv6/netfilter/ip6t_SYNPROXY.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netf

Re: [PATCH nf v4 2/2] netfilter: helper: Fix possible panic caused by invoking expectfn unloaded

2017-03-29 Thread Pablo Neira Ayuso
Hi Feng, Still two concerns with this. On Wed, Mar 22, 2017 at 09:03:24AM +0800, gfree.w...@foxmail.com wrote: > diff --git a/net/netfilter/nf_conntrack_helper.c > b/net/netfilter/nf_conntrack_helper.c > index 0eaa01e..c25c9be 100644 > --- a/net/netfilter/nf_conntrack_helper.c > +++ b/net/netfil

Re: [PATCH v2] netfilter: Clean up tests if NULL returned on failure

2017-03-29 Thread Jan Engelhardt
On Wednesday 2017-03-29 11:15, SIMRAN SINGHAL wrote: >> dest = kzalloc(sizeof(struct ip_vs_dest), GFP_KERNEL); >>- if (dest == NULL) >>+ if (!dest) >> return -ENOMEM; > >But, according to me we should prefer !var over ( var ==NULL ) according to the >c

Re: [PATCH v2] netfilter: Clean up tests if NULL returned on failure

2017-03-29 Thread SIMRAN SINGHAL
On Wed, Mar 29, 2017 at 2:19 PM, SIMRAN SINGHAL wrote: > On Wed, Mar 29, 2017 at 12:25 PM, Jan Engelhardt wrote: >> >> On Tuesday 2017-03-28 18:23, SIMRAN SINGHAL wrote: >>>On Tue, Mar 28, 2017 at 7:24 PM, Jan Engelhardt wrote: On Tuesday 2017-03-28 15:13, simran singhal wrote: >So

[PATCH] net: ipv6: Removed unnecessary parenthesis

2017-03-29 Thread Arushi Singhal
Removed parentheses on the right hand side of assignment, as they are not required. The following coccinelle script was used to fix this issue: @@ local idexpression id; expression e; @@ id = -( e -) Signed-off-by: Arushi Singhal --- net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++-- 1 file cha

Re: [PATCH v2] netfilter: Clean up tests if NULL returned on failure

2017-03-29 Thread SIMRAN SINGHAL
On Wed, Mar 29, 2017 at 12:25 PM, Jan Engelhardt wrote: > > On Tuesday 2017-03-28 18:23, SIMRAN SINGHAL wrote: >>On Tue, Mar 28, 2017 at 7:24 PM, Jan Engelhardt wrote: >>> On Tuesday 2017-03-28 15:13, simran singhal wrote: >>> Some functions like kmalloc/kzalloc return NULL on failure. When N

[PATCH] net: ipv6: netfilter: Format block comments.

2017-03-29 Thread Arushi Singhal
Fix checkpatch warnings: WARNING: Block comments use a trailing */ on a separate line WARNING: Block comments use * on subsequent lines Signed-off-by: Arushi Singhal --- net/ipv6/netfilter/ip6_tables.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/ipv6/