<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/net/netfilter/xt_socket.c, branch v4.20</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.20</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.20'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2018-09-28T12:47:41Z</updated>
<entry>
<title>netfilter: xt_socket: check sk before checking for netns.</title>
<updated>2018-09-28T12:47:41Z</updated>
<author>
<name>Flavio Leitner</name>
<email>fbl@redhat.com</email>
</author>
<published>2018-09-27T22:36:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=40e4f26e6a14fc1496eabb8b0004a547303114e6'/>
<id>urn:sha1:40e4f26e6a14fc1496eabb8b0004a547303114e6</id>
<content type='text'>
Only check for the network namespace if the socket is available.

Fixes: f564650106a6 ("netfilter: check if the socket netns is correct.")
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Flavio Leitner &lt;fbl@redhat.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: check if the socket netns is correct.</title>
<updated>2018-06-28T13:21:32Z</updated>
<author>
<name>Flavio Leitner</name>
<email>fbl@redhat.com</email>
</author>
<published>2018-06-27T13:34:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f564650106a6e85702660fefd59fdff0877ab46a'/>
<id>urn:sha1:f564650106a6e85702660fefd59fdff0877ab46a</id>
<content type='text'>
Netfilter assumes that if the socket is present in the skb, then
it can be used because that reference is cleaned up while the skb
is crossing netns.

We want to change that to preserve the socket reference in a future
patch, so this is a preparation updating netfilter to check if the
socket netns matches before use it.

Signed-off-by: Flavio Leitner &lt;fbl@redhat.com&gt;
Acked-by: Florian Westphal &lt;fw@strlen.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netfilter: Decrease code duplication regarding transparent socket option</title>
<updated>2018-06-02T22:02:01Z</updated>
<author>
<name>Máté Eckl</name>
<email>ecklm94@gmail.com</email>
</author>
<published>2018-06-01T12:54:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8d6e555773690e6fdefd99723fcd0a7e432c0c90'/>
<id>urn:sha1:8d6e555773690e6fdefd99723fcd0a7e432c0c90</id>
<content type='text'>
There is a function in include/net/netfilter/nf_socket.h to decide if a
socket has IP(V6)_TRANSPARENT socket option set or not. However this
does the same as inet_sk_transparent() in include/net/tcp.h

include/net/tcp.h:1733
/* This helper checks if socket has IP_TRANSPARENT set */
static inline bool inet_sk_transparent(const struct sock *sk)
{
	switch (sk-&gt;sk_state) {
	case TCP_TIME_WAIT:
		return inet_twsk(sk)-&gt;tw_transparent;
	case TCP_NEW_SYN_RECV:
		return inet_rsk(inet_reqsk(sk))-&gt;no_srccheck;
	}
	return inet_sk(sk)-&gt;transparent;
}

tproxy_sk_is_transparent has also been refactored to use this function
instead of reimplementing it.

Signed-off-by: Máté Eckl &lt;ecklm94@gmail.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: x_tables: use pr ratelimiting in all remaining spots</title>
<updated>2018-02-14T20:05:38Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2018-02-09T14:52:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b26066447bb8599b393b2dd2bbeb68767e09ba07'/>
<id>urn:sha1:b26066447bb8599b393b2dd2bbeb68767e09ba07</id>
<content type='text'>
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: xt_socket: Restore mark from full sockets only</title>
<updated>2017-09-26T18:04:34Z</updated>
<author>
<name>Subash Abhinov Kasiviswanathan</name>
<email>subashab@codeaurora.org</email>
</author>
<published>2017-09-22T01:01:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=89fcbb564f4a64c439d597c2702f990eed49c8a1'/>
<id>urn:sha1:89fcbb564f4a64c439d597c2702f990eed49c8a1</id>
<content type='text'>
An out of bounds error was detected on an ARM64 target with
Android based kernel 4.9. This occurs while trying to
restore mark on a skb from an inet request socket.

BUG: KASAN: slab-out-of-bounds in socket_match.isra.2+0xc8/0x1f0 net/netfilter/xt_socket.c:248
Read of size 4 at addr ffffffc06a8d824c by task syz-fuzzer/1532
CPU: 7 PID: 1532 Comm: syz-fuzzer Tainted: G        W  O    4.9.41+ #1
Call trace:
[&lt;ffffff900808d2f8&gt;] dump_backtrace+0x0/0x440 arch/arm64/kernel/traps.c:76
[&lt;ffffff900808d760&gt;] show_stack+0x28/0x38 arch/arm64/kernel/traps.c:226
[&lt;ffffff90085f7dc8&gt;] __dump_stack lib/dump_stack.c:15 [inline]
[&lt;ffffff90085f7dc8&gt;] dump_stack+0xe4/0x134 lib/dump_stack.c:51
[&lt;ffffff900830f358&gt;] print_address_description+0x68/0x258 mm/kasan/report.c:248
[&lt;ffffff900830f770&gt;] kasan_report_error mm/kasan/report.c:347 [inline]
[&lt;ffffff900830f770&gt;] kasan_report.part.2+0x228/0x2f0 mm/kasan/report.c:371
[&lt;ffffff900830fdec&gt;] kasan_report+0x5c/0x70 mm/kasan/report.c:372
[&lt;ffffff900830de98&gt;] check_memory_region_inline mm/kasan/kasan.c:308 [inline]
[&lt;ffffff900830de98&gt;] __asan_load4+0x88/0xa0 mm/kasan/kasan.c:740
[&lt;ffffff90097498f8&gt;] socket_match.isra.2+0xc8/0x1f0 net/netfilter/xt_socket.c:248
[&lt;ffffff9009749a5c&gt;] socket_mt4_v1_v2_v3+0x3c/0x48 net/netfilter/xt_socket.c:272
[&lt;ffffff90097f7e4c&gt;] ipt_do_table+0x54c/0xad8 net/ipv4/netfilter/ip_tables.c:311
[&lt;ffffff90097fcf14&gt;] iptable_mangle_hook+0x6c/0x220 net/ipv4/netfilter/iptable_mangle.c:90
...
Allocated by task 1532:
 save_stack_trace_tsk+0x0/0x2a0 arch/arm64/kernel/stacktrace.c:131
 save_stack_trace+0x28/0x38 arch/arm64/kernel/stacktrace.c:215
 save_stack mm/kasan/kasan.c:495 [inline]
 set_track mm/kasan/kasan.c:507 [inline]
 kasan_kmalloc+0xd8/0x188 mm/kasan/kasan.c:599
 kasan_slab_alloc+0x14/0x20 mm/kasan/kasan.c:537
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2728 [inline]
 slab_alloc mm/slub.c:2736 [inline]
 kmem_cache_alloc+0x14c/0x2e8 mm/slub.c:2741
 reqsk_alloc include/net/request_sock.h:87 [inline]
 inet_reqsk_alloc+0x4c/0x238 net/ipv4/tcp_input.c:6236
 tcp_conn_request+0x2b0/0xea8 net/ipv4/tcp_input.c:6341
 tcp_v4_conn_request+0xe0/0x100 net/ipv4/tcp_ipv4.c:1256
 tcp_rcv_state_process+0x384/0x18a8 net/ipv4/tcp_input.c:5926
 tcp_v4_do_rcv+0x2f0/0x3e0 net/ipv4/tcp_ipv4.c:1430
 tcp_v4_rcv+0x1278/0x1350 net/ipv4/tcp_ipv4.c:1709
 ip_local_deliver_finish+0x174/0x3e0 net/ipv4/ip_input.c:216

v1-&gt;v2: Change socket_mt6_v1_v2_v3() as well as mentioned by Eric
v2-&gt;v3: Put the correct fixes tag

Fixes: 01555e74bde5 ("netfilter: xt_socket: add XT_SOCKET_RESTORESKMARK flag")
Signed-off-by: Subash Abhinov Kasiviswanathan &lt;subashab@codeaurora.org&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: xt_socket: Fix broken IPv6 handling</title>
<updated>2017-04-24T18:06:29Z</updated>
<author>
<name>Peter Tirsek</name>
<email>peter@tirsek.com</email>
</author>
<published>2017-04-18T17:39:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6bd3d1929246bb0cf4f3bd6e25a0ba442b0de845'/>
<id>urn:sha1:6bd3d1929246bb0cf4f3bd6e25a0ba442b0de845</id>
<content type='text'>
Commit 834184b1f3a4 ("netfilter: defrag: only register defrag
functionality if needed") used the outdated XT_SOCKET_HAVE_IPV6 macro
which was removed earlier in commit 8db4c5be88f6 ("netfilter: move
socket lookup infrastructure to nf_socket_ipv{4,6}.c"). With that macro
never being defined, the xt_socket match emits an "Unknown family 10"
warning when used with IPv6:

WARNING: CPU: 0 PID: 1377 at net/netfilter/xt_socket.c:160 socket_mt_enable_defrag+0x47/0x50 [xt_socket]
Unknown family 10
Modules linked in: xt_socket nf_socket_ipv4 nf_socket_ipv6 nf_defrag_ipv4 [...]
CPU: 0 PID: 1377 Comm: ip6tables-resto Not tainted 4.10.10 #1
Hardware name: [...]
Call Trace:
? __warn+0xe7/0x100
? socket_mt_enable_defrag+0x47/0x50 [xt_socket]
? socket_mt_enable_defrag+0x47/0x50 [xt_socket]
? warn_slowpath_fmt+0x39/0x40
? socket_mt_enable_defrag+0x47/0x50 [xt_socket]
? socket_mt_v2_check+0x12/0x40 [xt_socket]
? xt_check_match+0x6b/0x1a0 [x_tables]
? xt_find_match+0x93/0xd0 [x_tables]
? xt_request_find_match+0x20/0x80 [x_tables]
? translate_table+0x48e/0x870 [ip6_tables]
? translate_table+0x577/0x870 [ip6_tables]
? walk_component+0x3a/0x200
? kmalloc_order+0x1d/0x50
? do_ip6t_set_ctl+0x181/0x490 [ip6_tables]
? filename_lookup+0xa5/0x120
? nf_setsockopt+0x3a/0x60
? ipv6_setsockopt+0xb0/0xc0
? sock_common_setsockopt+0x23/0x30
? SyS_socketcall+0x41d/0x630
? vfs_read+0xfa/0x120
? do_fast_syscall_32+0x7a/0x110
? entry_SYSENTER_32+0x47/0x71

This patch brings the conditional back in line with how the rest of the
file handles IPv6.

Fixes: 834184b1f3a4 ("netfilter: defrag: only register defrag functionality if needed")
Signed-off-by: Peter Tirsek &lt;peter@tirsek.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: defrag: only register defrag functionality if needed</title>
<updated>2016-12-06T20:42:00Z</updated>
<author>
<name>Florian Westphal</name>
<email>fw@strlen.de</email>
</author>
<published>2016-11-15T20:36:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=834184b1f3a4635efbdfdae5fb437f109f6605fa'/>
<id>urn:sha1:834184b1f3a4635efbdfdae5fb437f109f6605fa</id>
<content type='text'>
nf_defrag modules for ipv4 and ipv6 export an empty stub function.
Any module that needs the defragmentation hooks registered simply 'calls'
this empty function to create a phony module dependency -- modprobe will
then load the defrag module too.

This extends netfilter ipv4/ipv6 defragmentation modules to delay the hook
registration until the functionality is requested within a network namespace
instead of module load time for all namespaces.

Hooks are only un-registered on module unload or when a namespace that used
such defrag functionality exits.

We have to use struct net for this as the register hooks can be called
before netns initialization here from the ipv4/ipv6 conntrack module
init path.

There is no unregister functionality support, defrag will always be
active once it was requested inside a net namespace.

The reason is that defrag has impact on nft and iptables rulesets
(without defrag we might see framents).

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: x_tables: move hook state into xt_action_param structure</title>
<updated>2016-11-03T09:56:21Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2016-11-03T09:56:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=613dbd95723aee7abd16860745691b6c7bda20dc'/>
<id>urn:sha1:613dbd95723aee7abd16860745691b6c7bda20dc</id>
<content type='text'>
Place pointer to hook state in xt_action_param structure instead of
copying the fields that we need. After this change xt_action_param fits
into one cacheline.

This patch also adds a set of new wrapper functions to fetch relevant
hook state structure fields.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>netfilter: move socket lookup infrastructure to nf_socket_ipv{4,6}.c</title>
<updated>2016-11-01T19:50:31Z</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2016-10-27T18:49:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8db4c5be88f62ffd7a552f70687a10c614dc697b'/>
<id>urn:sha1:8db4c5be88f62ffd7a552f70687a10c614dc697b</id>
<content type='text'>
We need this split to reuse existing codebase for the upcoming nf_tables
socket expression.

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
</content>
</entry>
<entry>
<title>tcp/dccp: do not touch listener sk_refcnt under synflood</title>
<updated>2016-04-05T02:11:20Z</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2016-04-01T15:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3b24d854cb35383c30642116e5992fd619bdc9bc'/>
<id>urn:sha1:3b24d854cb35383c30642116e5992fd619bdc9bc</id>
<content type='text'>
When a SYNFLOOD targets a non SO_REUSEPORT listener, multiple
cpus contend on sk-&gt;sk_refcnt and sk-&gt;sk_wmem_alloc changes.

By letting listeners use SOCK_RCU_FREE infrastructure,
we can relax TCP_LISTEN lookup rules and avoid touching sk_refcnt

Note that we still use SLAB_DESTROY_BY_RCU rules for other sockets,
only listeners are impacted by this change.

Peak performance under SYNFLOOD is increased by ~33% :

On my test machine, I could process 3.2 Mpps instead of 2.4 Mpps

Most consuming functions are now skb_set_owner_w() and sock_wfree()
contending on sk-&gt;sk_wmem_alloc when cooking SYNACK and freeing them.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
