<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/include/net/netfilter, branch v4.2</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.2</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2015-07-20T12:58:19Z</updated>
<entry>
<title>netfilter: fix netns dependencies with conntrack templates</title>
<updated>2015-07-20T12:58:19Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-07-13T13:11:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0838aa7fcfcd875caa7bcc5dab0c3fd40444553d'/>
<id>urn:sha1:0838aa7fcfcd875caa7bcc5dab0c3fd40444553d</id>
<content type='text'>
Quoting Daniel Borkmann:

"When adding connection tracking template rules to a netns, f.e. to
configure netfilter zones, the kernel will endlessly busy-loop as soon
as we try to delete the given netns in case there's at least one
template present, which is problematic i.e. if there is such bravery that
the priviledged user inside the netns is assumed untrusted.

Minimal example:

  ip netns add foo
  ip netns exec foo iptables -t raw -A PREROUTING -d 1.2.3.4 -j CT --zone 1
  ip netns del foo

What happens is that when nf_ct_iterate_cleanup() is being called from
nf_conntrack_cleanup_net_list() for a provided netns, we always end up
with a net-&gt;ct.count &gt; 0 and thus jump back to i_see_dead_people. We
don't get a soft-lockup as we still have a schedule() point, but the
serving CPU spins on 100% from that point onwards.

Since templates are normally allocated with nf_conntrack_alloc(), we
also bump net-&gt;ct.count. The issue why they are not yet nf_ct_put() is
because the per netns .exit() handler from x_tables (which would eventually
invoke xt_CT's xt_ct_tg_destroy() that drops reference on info-&gt;ct) is
called in the dependency chain at a *later* point in time than the per
netns .exit() handler for the connection tracker.

This is clearly a chicken'n'egg problem: after the connection tracker
.exit() handler, we've teared down all the connection tracking
infrastructure already, so rightfully, xt_ct_tg_destroy() cannot be
invoked at a later point in time during the netns cleanup, as that would
lead to a use-after-free. At the same time, we cannot make x_tables depend
on the connection tracker module, so that the xt_ct_tg_destroy() would
be invoked earlier in the cleanup chain."

Daniel confirms this has to do with the order in which modules are loaded or
having compiled nf_conntrack as modules while x_tables built-in. So we have no
guarantees regarding the order in which netns callbacks are executed.

Fix this by allocating the templates through kmalloc() from the respective
SYNPROXY and CT targets, so they don't depend on the conntrack kmem cache.
Then, release then via nf_ct_tmpl_free() from destroy_conntrack(). This branch
is marked as unlikely since conntrack templates are rarely allocated and only
from the configuration plane path.

Note that templates are not kept in any list to avoid further dependencies with
nf_conntrack anymore, thus, the tmpl larval list is removed.

Reported-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Tested-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_qeueue: Drop queue entries on nf_unregister_hook</title>
<updated>2015-06-23T13:23:23Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2015-06-19T19:03:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8405a8fff3f8545c888a872d6e3c0c8eecd4d348'/>
<id>urn:sha1:8405a8fff3f8545c888a872d6e3c0c8eecd4d348</id>
<content type='text'>
Add code to nf_unregister_hook to flush the nf_queue when a hook is
unregistered.  This guarantees that the pointer that the nf_queue code
retains into the nf_hook list will remain valid while a packet is
queued.

I tested what would happen if we do not flush queued packets and was
trivially able to obtain the oops below.  All that was required was
to stop the nf_queue listening process, to delete all of the nf_tables,
and to awaken the nf_queue listening process.

&gt; BUG: unable to handle kernel paging request at 0000000100000001
&gt; IP: [&lt;0000000100000001&gt;] 0x100000001
&gt; PGD b9c35067 PUD 0
&gt; Oops: 0010 [#1] SMP
&gt; Modules linked in:
&gt; CPU: 0 PID: 519 Comm: lt-nfqnl_test Not tainted
&gt; task: ffff8800b9c8c050 ti: ffff8800ba9d8000 task.ti: ffff8800ba9d8000
&gt; RIP: 0010:[&lt;0000000100000001&gt;]  [&lt;0000000100000001&gt;] 0x100000001
&gt; RSP: 0018:ffff8800ba9dba40  EFLAGS: 00010a16
&gt; RAX: ffff8800bab48a00 RBX: ffff8800ba9dba90 RCX: ffff8800ba9dba90
&gt; RDX: ffff8800b9c10128 RSI: ffff8800ba940900 RDI: ffff8800bab48a00
&gt; RBP: ffff8800b9c10128 R08: ffffffff82976660 R09: ffff8800ba9dbb28
&gt; R10: dead000000100100 R11: dead000000200200 R12: ffff8800ba940900
&gt; R13: ffffffff8313fd50 R14: ffff8800b9c95200 R15: 0000000000000000
&gt; FS:  00007fb91fc34700(0000) GS:ffff8800bfa00000(0000) knlGS:0000000000000000
&gt; CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
&gt; CR2: 0000000100000001 CR3: 00000000babfb000 CR4: 00000000000007f0
&gt; Stack:
&gt;  ffffffff8206ab0f ffffffff82982240 ffff8800bab48a00 ffff8800b9c100a8
&gt;  ffff8800b9c10100 0000000000000001 ffff8800ba940900 ffff8800b9c10128
&gt;  ffffffff8206bd65 ffff8800bfb0d5e0 ffff8800bab48a00 0000000000014dc0
&gt; Call Trace:
&gt;  [&lt;ffffffff8206ab0f&gt;] ? nf_iterate+0x4f/0xa0
&gt;  [&lt;ffffffff8206bd65&gt;] ? nf_reinject+0x125/0x190
&gt;  [&lt;ffffffff8206dee5&gt;] ? nfqnl_recv_verdict+0x255/0x360
&gt;  [&lt;ffffffff81386290&gt;] ? nla_parse+0x80/0xf0
&gt;  [&lt;ffffffff8206c42c&gt;] ? nfnetlink_rcv_msg+0x13c/0x240
&gt;  [&lt;ffffffff811b2fec&gt;] ? __memcg_kmem_get_cache+0x4c/0x150
&gt;  [&lt;ffffffff8206c2f0&gt;] ? nfnl_lock+0x20/0x20
&gt;  [&lt;ffffffff82068159&gt;] ? netlink_rcv_skb+0xa9/0xc0
&gt;  [&lt;ffffffff820677bf&gt;] ? netlink_unicast+0x12f/0x1c0
&gt;  [&lt;ffffffff82067ade&gt;] ? netlink_sendmsg+0x28e/0x650
&gt;  [&lt;ffffffff81fdd814&gt;] ? sock_sendmsg+0x44/0x50
&gt;  [&lt;ffffffff81fde07b&gt;] ? ___sys_sendmsg+0x2ab/0x2c0
&gt;  [&lt;ffffffff810e8f73&gt;] ? __wake_up+0x43/0x70
&gt;  [&lt;ffffffff8141a134&gt;] ? tty_write+0x1c4/0x2a0
&gt;  [&lt;ffffffff81fde9f4&gt;] ? __sys_sendmsg+0x44/0x80
&gt;  [&lt;ffffffff823ff8d7&gt;] ? system_call_fastpath+0x12/0x6a
&gt; Code:  Bad RIP value.
&gt; RIP  [&lt;0000000100000001&gt;] 0x100000001
&gt;  RSP &lt;ffff8800ba9dba40&gt;
&gt; CR2: 0000000100000001
&gt; ---[ end trace 08eb65d42362793f ]---

Cc: stable@vger.kernel.org
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: bridge: split ipv6 code into separated file</title>
<updated>2015-06-18T19:14:21Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-06-16T12:07:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=230ac490f7fba2aea52914c69d14b15dd515e49c'/>
<id>urn:sha1:230ac490f7fba2aea52914c69d14b15dd515e49c</id>
<content type='text'>
Resolve compilation breakage when CONFIG_IPV6 is not set by moving the IPv6
code into a separated br_netfilter_ipv6.c file.

Fixes: efb6de9b4ba0 ("netfilter: bridge: forward IPv6 fragmented packets")
Reported-by: kbuild test robot &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables_netdev: unregister hooks on net_device removal</title>
<updated>2015-06-15T21:02:35Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-06-15T10:12:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=835b803377f5f11f9ccf234f70ed667a82605c45'/>
<id>urn:sha1:835b803377f5f11f9ccf234f70ed667a82605c45</id>
<content type='text'>
In case the net_device is gone, we have to unregister the hooks and put back
the reference on the net_device object. Once it comes back, register them
again. This also covers the device rename case.

This patch also adds a new flag to indicate that the basechain is disabled, so
their hooks are not registered. This flag is used by the netdev family to
handle the case where the net_device object is gone. Currently this flag is not
exposed to userspace.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: attach net_device to basechain</title>
<updated>2015-06-15T21:02:31Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-06-12T11:55:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2cbce139fc57bc2625f88add055d0b94f00c3352'/>
<id>urn:sha1:2cbce139fc57bc2625f88add055d0b94f00c3352</id>
<content type='text'>
The device is part of the hook configuration, so instead of a global
configuration per table, set it to each of the basechain that we create.

This patch reworks ebddf1a8d78a ("netfilter: nf_tables: allow to bind table to
net_device").

Note that this adds a dev_name field in the nft_base_chain structure which is
required the netdev notification subscription that follows up in a patch to
handle gone net_devices.

Suggested-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: allow to bind table to net_device</title>
<updated>2015-05-26T16:41:17Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2015-05-26T16:41:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ebddf1a8d78aa3436353fae75c4396e50cb2d6cf'/>
<id>urn:sha1:ebddf1a8d78aa3436353fae75c4396e50cb2d6cf</id>
<content type='text'>
This patch adds the internal NFT_AF_NEEDS_DEV flag to indicate that you must
attach this table to a net_device.

This change is required by the follow up patch that introduces the new netdev
table.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: mark stateful expressions</title>
<updated>2015-04-13T18:12:31Z</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2015-04-11T09:46:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=151d799a61da1b6f6b7e5116fb776177917bbe9a'/>
<id>urn:sha1:151d799a61da1b6f6b7e5116fb776177917bbe9a</id>
<content type='text'>
Add a flag to mark stateful expressions.

This is used for dynamic expression instanstiation to limit the usable
expressions. Strictly speaking only the dynset expression can not be
used in order to avoid recursion, but since dynamically instantiating
non-stateful expressions will simply create an identical copy, which
behaves no differently than the original, this limits to expressions
where it actually makes sense to dynamically instantiate them.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: prepare for expressions associated to set elements</title>
<updated>2015-04-13T18:12:31Z</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2015-04-11T09:46:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f25ad2e907f110378159fe5e088aa13176faaa5b'/>
<id>urn:sha1:f25ad2e907f110378159fe5e088aa13176faaa5b</id>
<content type='text'>
Preparation to attach expressions to set elements: add a set extension
type to hold an expression and dump the expression information with the
set element.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: add helper functions for expression handling</title>
<updated>2015-04-13T18:12:31Z</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2015-04-11T09:46:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0b2d8a7b638b5034d2d68f6add8af94daaa1d4cd'/>
<id>urn:sha1:0b2d8a7b638b5034d2d68f6add8af94daaa1d4cd</id>
<content type='text'>
Add helper functions for initializing, cloning, dumping and destroying
a single expression that is not part of a rule.

Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: nf_tables: variable sized set element keys / data</title>
<updated>2015-04-13T15:17:31Z</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2015-04-11T01:27:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7d7402642eaf385aef0772eff5a35e34fc4995d7'/>
<id>urn:sha1:7d7402642eaf385aef0772eff5a35e34fc4995d7</id>
<content type='text'>
This patch changes sets to support variable sized set element keys / data
up to 64 bytes each by using variable sized set extensions. This allows
to use concatenations with bigger data items suchs as IPv6 addresses.

As a side effect, small keys/data now don't require the full 16 bytes
of struct nft_data anymore but just the space they need.

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