<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/net/netfilter/nf_queue.c, 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-10-20T17:59:59Z</updated>
<entry>
<title>netfilter: fix nf_queue handling</title>
<updated>2016-10-20T17:59:59Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2016-10-17T17:05:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7034b566a4e7d550621c2dfafd380b77b3787cd9'/>
<id>urn:sha1:7034b566a4e7d550621c2dfafd380b77b3787cd9</id>
<content type='text'>
nf_queue handling is broken since e3b37f11e6e4 ("netfilter: replace
list_head with single linked list") for two reasons:

1) If the bypass flag is set on, there are no userspace listeners and
   we still have more hook entries to iterate over, then jump to the
   next hook. Otherwise accept the packet. On nf_reinject() path, the
   okfn() needs to be invoked.

2) We should not re-enter the same hook on packet reinjection. If the
   packet is accepted, we have to skip the current hook from where the
   packet was enqueued, otherwise the packets gets enqueued over and
   over again.

This restores the previous list_for_each_entry_continue() behaviour
happening from nf_iterate() that was dealing with these two cases.
This patch introduces a new nf_queue() wrapper function so this fix
becomes simpler.

Fixes: e3b37f11e6e4 ("netfilter: replace list_head with single linked list")
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: replace list_head with single linked list</title>
<updated>2016-09-25T12:38:48Z</updated>
<author>
<name>Aaron Conole</name>
<email>aconole@bytheb.org</email>
</author>
<published>2016-09-21T15:35:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e3b37f11e6e4e6b6f02cc762f182ce233d2c1c9d'/>
<id>urn:sha1:e3b37f11e6e4e6b6f02cc762f182ce233d2c1c9d</id>
<content type='text'>
The netfilter hook list never uses the prev pointer, and so can be trimmed to
be a simple singly-linked list.

In addition to having a more light weight structure for hook traversal,
struct net becomes 5568 bytes (down from 6400) and struct net_device becomes
2176 bytes (down from 2240).

Signed-off-by: Aaron Conole &lt;aconole@bytheb.org&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_queue: Make the queue_handler pernet</title>
<updated>2016-05-25T09:54:22Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2016-05-14T02:18:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dc3ee32e96d74dd6c80eed63af5065cb75899299'/>
<id>urn:sha1:dc3ee32e96d74dd6c80eed63af5065cb75899299</id>
<content type='text'>
Florian Weber reported:
&gt; Under full load (unshare() in loop -&gt; OOM conditions) we can
&gt; get kernel panic:
&gt;
&gt; BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
&gt; IP: [&lt;ffffffff81476c85&gt;] nfqnl_nf_hook_drop+0x35/0x70
&gt; [..]
&gt; task: ffff88012dfa3840 ti: ffff88012dffc000 task.ti: ffff88012dffc000
&gt; RIP: 0010:[&lt;ffffffff81476c85&gt;]  [&lt;ffffffff81476c85&gt;] nfqnl_nf_hook_drop+0x35/0x70
&gt; RSP: 0000:ffff88012dfffd80  EFLAGS: 00010206
&gt; RAX: 0000000000000008 RBX: ffffffff81add0c0 RCX: ffff88013fd80000
&gt; [..]
&gt; Call Trace:
&gt;  [&lt;ffffffff81474d98&gt;] nf_queue_nf_hook_drop+0x18/0x20
&gt;  [&lt;ffffffff814738eb&gt;] nf_unregister_net_hook+0xdb/0x150
&gt;  [&lt;ffffffff8147398f&gt;] netfilter_net_exit+0x2f/0x60
&gt;  [&lt;ffffffff8141b088&gt;] ops_exit_list.isra.4+0x38/0x60
&gt;  [&lt;ffffffff8141b652&gt;] setup_net+0xc2/0x120
&gt;  [&lt;ffffffff8141bd09&gt;] copy_net_ns+0x79/0x120
&gt;  [&lt;ffffffff8106965b&gt;] create_new_namespaces+0x11b/0x1e0
&gt;  [&lt;ffffffff810698a7&gt;] unshare_nsproxy_namespaces+0x57/0xa0
&gt;  [&lt;ffffffff8104baa2&gt;] SyS_unshare+0x1b2/0x340
&gt;  [&lt;ffffffff81608276&gt;] entry_SYSCALL_64_fastpath+0x1e/0xa8
&gt; Code: 65 00 48 89 e5 41 56 41 55 41 54 53 83 e8 01 48 8b 97 70 12 00 00 48 98 49 89 f4 4c 8b 74 c2 18 4d 8d 6e 08 49 81 c6 88 00 00 00 &lt;49&gt; 8b 5d 00 48 85 db 74 1a 48 89 df 4c 89 e2 48 c7 c6 90 68 47
&gt;

The simple fix for this requires a new pernet variable for struct
nf_queue that indicates when it is safe to use the dynamically
allocated nf_queue state.

As we need a variable anyway make nf_register_queue_handler and
nf_unregister_queue_handler pernet.  This allows the existing logic of
when it is safe to use the state from the nfnetlink_queue module to be
reused with no changes except for making it per net.

The syncrhonize_rcu from nf_unregister_queue_handler is moved to a new
function nfnl_queue_net_exit_batch so that the worst case of having a
syncrhonize_rcu in the pernet exit path is not experienced in batch
mode.

Reported-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Acked-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_queue: remove rcu_read_lock calls</title>
<updated>2015-10-16T16:22:41Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2015-10-13T12:33:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=81b4325eba6baae80a70d1af866278af38fb6cdd'/>
<id>urn:sha1:81b4325eba6baae80a70d1af866278af38fb6cdd</id>
<content type='text'>
All verdict handlers make use of the nfnetlink .call_rcu callback
so rcu readlock is already held.

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: make nf_queue_entry_get_refs return void</title>
<updated>2015-10-16T16:22:23Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2015-10-13T12:33:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ed78d09d59ba9764b7454e8e1ccbb0072a55b6d7'/>
<id>urn:sha1:ed78d09d59ba9764b7454e8e1ccbb0072a55b6d7</id>
<content type='text'>
We don't care if module is being unloaded anymore since hook unregister
handling will destroy queue entries using that hook.

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: remove hook owner refcounting</title>
<updated>2015-10-16T16:21:39Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2015-10-13T12:33:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2ffbceb2b08f8ca0496c54a9ebcd11d25275954e'/>
<id>urn:sha1:2ffbceb2b08f8ca0496c54a9ebcd11d25275954e</id>
<content type='text'>
since commit 8405a8fff3f8 ("netfilter: nf_qeueue: Drop queue entries on
nf_unregister_hook") all pending queued entries are discarded.

So we can simply remove all of the owner handling -- when module is
removed it also needs to unregister all its hooks.

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: nfqueue: don't use prev pointer</title>
<updated>2015-10-13T10:03:24Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2015-10-09T11:10:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7ceebfe46ec026b5405416b72772ac5aa9e09e84'/>
<id>urn:sha1:7ceebfe46ec026b5405416b72772ac5aa9e09e84</id>
<content type='text'>
Usage of -prev seems buggy.  While packet was out our hook cannot be
removed but we have no way to know if the previous one is still valid.

So better not use -&gt;prev at all.  Since NF_REPEAT just asks to invoke
same hook function again, just do so, and continue with nf_interate
if we get an ACCEPT verdict.

A side effect of this change is that if nf_reinject(NF_REPEAT) causes
another REPEAT we will now drop the skb instead of a kernel loop.

However, NF_REPEAT loops would be a bug so this should not happen anyway.

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: Push struct net down into nf_afinfo.reroute</title>
<updated>2015-09-29T18:21:31Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2015-09-25T20:07:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d815d90bbbc08777c0e3a36f57b97fc4a4fb3150'/>
<id>urn:sha1:d815d90bbbc08777c0e3a36f57b97fc4a4fb3150</id>
<content type='text'>
The network namespace is needed when routing a packet.
Stop making nf_afinfo.reroute guess which network namespace
is the proper namespace to route the packet in.

Signed-off-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: Pass net into okfn</title>
<updated>2015-09-18T00:18:37Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2015-09-16T01:04:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0c4b51f0054ce85c0ec578ab818f0631834573eb'/>
<id>urn:sha1:0c4b51f0054ce85c0ec578ab818f0631834573eb</id>
<content type='text'>
This is immediately motivated by the bridge code that chains functions that
call into netfilter.  Without passing net into the okfns the bridge code would
need to guess about the best expression for the network namespace to process
packets in.

As net is frequently one of the first things computed in continuation functions
after netfilter has done it's job passing in the desired network namespace is in
many cases a code simplification.

To support this change the function dst_output_okfn is introduced to
simplify passing dst_output as an okfn.  For the moment dst_output_okfn
just silently drops the struct net.

Signed-off-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_queue: fix nf_queue_nf_hook_drop()</title>
<updated>2015-07-23T14:17:58Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-07-20T10:55:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2385eb0c5fbcb4316d3490b3affba8e15efc7eb8'/>
<id>urn:sha1:2385eb0c5fbcb4316d3490b3affba8e15efc7eb8</id>
<content type='text'>
This function reacquires the rtnl_lock() which is already held by
nf_unregister_hook().

This can be triggered via: modprobe nf_conntrack_ipv4 &amp;&amp; rmmod nf_conntrack_ipv4

[  720.628746] INFO: task rmmod:3578 blocked for more than 120 seconds.
[  720.628749]       Not tainted 4.2.0-rc2+ #113
[  720.628752] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  720.628754] rmmod           D ffff8800ca46fd58     0  3578   3571 0x00000080
[...]
[  720.628783] Call Trace:
[  720.628790]  [&lt;ffffffff8152ea0b&gt;] schedule+0x6b/0x90
[  720.628795]  [&lt;ffffffff8152ecb3&gt;] schedule_preempt_disabled+0x13/0x20
[  720.628799]  [&lt;ffffffff8152ff55&gt;] mutex_lock_nested+0x1f5/0x380
[  720.628803]  [&lt;ffffffff81462622&gt;] ? rtnl_lock+0x12/0x20
[  720.628807]  [&lt;ffffffff81462622&gt;] ? rtnl_lock+0x12/0x20
[  720.628812]  [&lt;ffffffff81462622&gt;] rtnl_lock+0x12/0x20
[  720.628817]  [&lt;ffffffff8148ab25&gt;] nf_queue_nf_hook_drop+0x15/0x160
[  720.628825]  [&lt;ffffffff81488d48&gt;] nf_unregister_net_hook+0x168/0x190
[  720.628831]  [&lt;ffffffff81488e24&gt;] nf_unregister_hook+0x64/0x80
[  720.628837]  [&lt;ffffffff81488e60&gt;] nf_unregister_hooks+0x20/0x30
[...]

Moreover, nf_unregister_net_hook() should only destroy the queue for this
netns, not for every netns.

Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Fixes: 085db2c04557 ("netfilter: Per network namespace netfilter hooks.")
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Acked-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
</content>
</entry>
</feed>
