<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/include/net/netfilter, branch v4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-11-24T13:43:35Z</updated>
<entry>
<title>netfilter: nat: fix crash when conntrack entry is re-used</title>
<updated>2016-11-24T13:43:35Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2016-11-23T00:11:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5173bc679dec881120df109a6a2b39143235382c'/>
<id>urn:sha1:5173bc679dec881120df109a6a2b39143235382c</id>
<content type='text'>
Stas Nichiporovich reports oops in nf_nat_bysource_cmp(), trying to
access nf_conn struct at address 0xffffffffffffff50.

This is the result of fetching a null rhash list (struct embedded at
offset 176; 0 - 176 gets us ...fff50).

The problem is that conntrack entries are allocated from a
SLAB_DESTROY_BY_RCU cache, i.e. entries can be free'd and reused
on another cpu while nf nat bysource hash access the same conntrack entry.

Freeing is fine (we hold rcu read lock); zeroing rhlist_head isn't.

-&gt; Move the rhlist struct outside of the memset()-inited area.

Fixes: 7c9664351980aaa6a ("netfilter: move nat hlist_head to nf_conn")
Reported-by: Stas Nichiporovich &lt;stasn77@gmail.com&gt;
Signed-off-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: fix inconsistent element expiration calculation</title>
<updated>2016-11-24T13:43:34Z</updated>
<author>
<name>Anders K. Pedersen</name>
<email>akp@cohaesio.com</email>
</author>
<published>2016-11-20T16:38:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d3e2a1110cae6ee5eeb1f9a97addf03e974f12e6'/>
<id>urn:sha1:d3e2a1110cae6ee5eeb1f9a97addf03e974f12e6</id>
<content type='text'>
As Liping Zhang reports, after commit a8b1e36d0d1d ("netfilter: nft_dynset:
fix element timeout for HZ != 1000"), priv-&gt;timeout was stored in jiffies,
while set-&gt;timeout was stored in milliseconds. This is inconsistent and
incorrect.

Firstly, we already call msecs_to_jiffies in nft_set_elem_init, so
priv-&gt;timeout will be converted to jiffies twice.

Secondly, if the user did not specify the NFTA_DYNSET_TIMEOUT attr,
set-&gt;timeout will be used, but we forget to call msecs_to_jiffies
when do update elements.

Fix this by using jiffies internally for traditional sets and doing the
conversions to/from msec when interacting with userspace - as dynset
already does.

This is preferable to doing the conversions, when elements are inserted or
updated, because this can happen very frequently on busy dynsets.

Fixes: a8b1e36d0d1d ("netfilter: nft_dynset: fix element timeout for HZ != 1000")
Reported-by: Liping Zhang &lt;zlpnobody@gmail.com&gt;
Signed-off-by: Anders K. Pedersen &lt;akp@cohaesio.com&gt;
Acked-by: Liping Zhang &lt;zlpnobody@gmail.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nat: switch to new rhlist interface</title>
<updated>2016-11-24T13:43:34Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2016-11-16T14:13:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7223ecd4669921cb2a709193521967aaa2b06862'/>
<id>urn:sha1:7223ecd4669921cb2a709193521967aaa2b06862</id>
<content type='text'>
I got offlist bug report about failing connections and high cpu usage.
This happens because we hit 'elasticity' checks in rhashtable that
refuses bucket list exceeding 16 entries.

The nat bysrc hash unfortunately needs to insert distinct objects that
share same key and are identical (have same source tuple), this cannot
be avoided.

Switch to the rhlist interface which is designed for this.

The nulls_base is removed here, I don't think its needed:

A (unlikely) false positive results in unneeded port clash resolution,
a false negative results in packet drop during conntrack confirmation,
when we try to insert the duplicate into main conntrack hash table.

Tested by adding multiple ip addresses to host, then adding
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

... and then creating multiple connections, from same source port but
different addresses:

for i in $(seq 2000 2032);do nc -p 1234 192.168.7.1 $i &gt; /dev/null  &amp; done

(all of these then get hashed to same bysource slot)

Then, to test that nat conflict resultion is working:

nc -s 10.0.0.1 -p 1234 192.168.7.1 2000
nc -s 10.0.0.2 -p 1234 192.168.7.1 2000

tcp  .. src=10.0.0.1 dst=192.168.7.1 sport=1234 dport=2000 src=192.168.7.1 dst=192.168.7.10 sport=2000 dport=1024 [ASSURED]
tcp  .. src=10.0.0.2 dst=192.168.7.1 sport=1234 dport=2000 src=192.168.7.1 dst=192.168.7.10 sport=2000 dport=1025 [ASSURED]
tcp  .. src=192.168.7.10 dst=192.168.7.1 sport=1234 dport=2000 src=192.168.7.1 dst=192.168.7.10 sport=2000 dport=1234 [ASSURED]
tcp  .. src=192.168.7.10 dst=192.168.7.1 sport=1234 dport=2001 src=192.168.7.1 dst=192.168.7.10 sport=2001 dport=1234 [ASSURED]
[..]

-&gt; nat altered source ports to 1024 and 1025, respectively.
This can also be confirmed on destination host which shows
ESTAB      0      0   192.168.7.1:2000      192.168.7.10:1024
ESTAB      0      0   192.168.7.1:2000      192.168.7.10:1025
ESTAB      0      0   192.168.7.1:2000      192.168.7.10:1234

Cc: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Fixes: 870190a9ec907 ("netfilter: nat: convert nat bysrc hash to rhashtable")
Signed-off-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: conntrack: avoid excess memory allocation</title>
<updated>2016-10-27T16:29:02Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2016-10-26T21:46:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cdb436d181d21af4d273b49ec7734eecd6a37fe9'/>
<id>urn:sha1:cdb436d181d21af4d273b49ec7734eecd6a37fe9</id>
<content type='text'>
This is now a fixed-size extension, so we don't need to pass a variable
alloc size.  This (harmless) error results in allocating 32 instead of
the needed 16 bytes for this extension as the size gets passed twice.

Fixes: 23014011ba420 ("netfilter: conntrack: support a fixed size of 128 distinct labels")
Signed-off-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: fix type mismatch with error return from nft_parse_u32_check</title>
<updated>2016-10-27T16:29:01Z</updated>
<author>
<name>John W. Linville</name>
<email>linville@tuxdriver.com</email>
</author>
<published>2016-10-25T19:56:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f1d505bb762e30bf316ff5d3b604914649d6aed3'/>
<id>urn:sha1:f1d505bb762e30bf316ff5d3b604914649d6aed3</id>
<content type='text'>
Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of
u32 netlink attributes") introduced nft_parse_u32_check with a return
value of "unsigned int", yet on error it returns "-ERANGE".

This patch corrects the mismatch by changing the return value to "int",
which happens to match the actual users of nft_parse_u32_check already.

Found by Coverity, CID 1373930.

Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error
handling in nft_exthdr_init()) attempted to address the issue, but
did not address the return type of nft_parse_u32_check.

Signed-off-by: John W. Linville &lt;linville@tuxdriver.com&gt;
Cc: Laura Garcia Liebana &lt;nevola@gmail.com&gt;
Cc: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Cc: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Fixes: 36b701fae12ac ("netfilter: nf_tables: validate maximum value...")
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: fix *leak* when expr clone fail</title>
<updated>2016-10-27T16:20:45Z</updated>
<author>
<name>Liping Zhang</name>
<email>zlpnobody@gmail.com</email>
</author>
<published>2016-10-22T10:51:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=61f9e2924f4981d626b3a931fed935f2fa3cb4de'/>
<id>urn:sha1:61f9e2924f4981d626b3a931fed935f2fa3cb4de</id>
<content type='text'>
When nft_expr_clone failed, a series of problems will happen:

1. module refcnt will leak, we call __module_get at the beginning but
   we forget to put it back if ops-&gt;clone returns fail
2. memory will be leaked, if clone fail, we just return NULL and forget
   to free the alloced element
3. set-&gt;nelems will become incorrect when set-&gt;size is specified. If
   clone fail, we should decrease the set-&gt;nelems

Now this patch fixes these problems. And fortunately, clone fail will
only happen on counter expression when memory is exhausted.

Fixes: 086f332167d6 ("netfilter: nf_tables: add clone interface to expression operations")
Signed-off-by: Liping Zhang &lt;zlpnobody@gmail.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: merge fixup for "nf_tables_netdev: remove redundant ip_hdr assignment"</title>
<updated>2016-10-06T00:25:48Z</updated>
<author>
<name>Stephen Rothwell</name>
<email>sfr@canb.auug.org.au</email>
</author>
<published>2016-09-13T00:08:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a44c984f1ef16229cdfd92326ad10118b1940ff9'/>
<id>urn:sha1:a44c984f1ef16229cdfd92326ad10118b1940ff9</id>
<content type='text'>
Signed-off-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Acked-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next</title>
<updated>2016-09-25T21:34:19Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2016-09-25T21:23:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f20fbc0717f9f007c94b2641134b19228d0ce9ed'/>
<id>urn:sha1:f20fbc0717f9f007c94b2641134b19228d0ce9ed</id>
<content type='text'>
Conflicts:
	net/netfilter/core.c
	net/netfilter/nf_tables_netdev.c

Resolve two conflicts before pull request for David's net-next tree:

1) Between c73c24849011 ("netfilter: nf_tables_netdev: remove redundant
   ip_hdr assignment") from the net tree and commit ddc8b6027ad0
   ("netfilter: introduce nft_set_pktinfo_{ipv4, ipv6}_validate()").

2) Between e8bffe0cf964 ("net: Add _nf_(un)register_hooks symbols") and
   Aaron Conole's patches to replace list_head with single linked list.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nft_log: complete NFTA_LOG_FLAGS attr support</title>
<updated>2016-09-25T21:16:43Z</updated>
<author>
<name>Liping Zhang</name>
<email>liping.zhang@spreadtrum.com</email>
</author>
<published>2016-09-25T08:35:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ff107d27761ff4b644c82c209e004ec9c8fbbc22'/>
<id>urn:sha1:ff107d27761ff4b644c82c209e004ec9c8fbbc22</id>
<content type='text'>
NFTA_LOG_FLAGS attribute is already supported, but the related
NF_LOG_XXX flags are not exposed to the userspace. So we cannot
explicitly enable log flags to log uid, tcp sequence, ip options
and so on, i.e. such rule "nft add rule filter output log uid"
is not supported yet.

So move NF_LOG_XXX macro definitions to the uapi/../nf_log.h. In
order to keep consistent with other modules, change NF_LOG_MASK to
refer to all supported log flags. On the other hand, add a new
NF_LOG_DEFAULT_MASK to refer to the original default log flags.

Finally, if user specify the unsupported log flags or NFTA_LOG_GROUP
and NFTA_LOG_FLAGS are set at the same time, report EINVAL to the
userspace.

Signed-off-by: Liping Zhang &lt;liping.zhang@spreadtrum.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: add range expression</title>
<updated>2016-09-25T21:16:42Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2016-09-23T13:23:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0f3cd9b3697708c86a825ae3cedabf7be6fd3e72'/>
<id>urn:sha1:0f3cd9b3697708c86a825ae3cedabf7be6fd3e72</id>
<content type='text'>
Inverse ranges != [a,b] are not currently possible because rules are
composites of &amp;&amp; operations, and we need to express this:

	data &lt; a || data &gt; b

This patch adds a new range expression. Positive ranges can be already
through two cmp expressions:

	cmp(sreg, data, &gt;=)
	cmp(sreg, data, &lt;=)

This new range expression provides an alternative way to express this.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
</feed>
