<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/net/netfilter, branch v3.2.99</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>netfilter: xt_TCPMSS: add more sanity tests on tcph-&gt;doff</title>
<updated>2018-02-13T18:32:22+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2017-04-03T17:55:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d84eeff84e9869d29f442ff652ce1352cfa63e84'/>
<id>d84eeff84e9869d29f442ff652ce1352cfa63e84</id>
<content type='text'>
commit 2638fd0f92d4397884fd991d8f4925cb3f081901 upstream.

Denys provided an awesome KASAN report pointing to an use
after free in xt_TCPMSS

I have provided three patches to fix this issue, either in xt_TCPMSS or
in xt_tcpudp.c. It seems xt_TCPMSS patch has the smallest possible
impact.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Reported-by: Denys Fedoryshchenko &lt;nuclearcat@nuclearcat.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 2638fd0f92d4397884fd991d8f4925cb3f081901 upstream.

Denys provided an awesome KASAN report pointing to an use
after free in xt_TCPMSS

I have provided three patches to fix this issue, either in xt_TCPMSS or
in xt_tcpudp.c. It seems xt_TCPMSS patch has the smallest possible
impact.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Reported-by: Denys Fedoryshchenko &lt;nuclearcat@nuclearcat.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_TCPMSS: correct return value in tcpmss_mangle_packet</title>
<updated>2018-02-13T18:32:21+00:00</updated>
<author>
<name>Phil Oester</name>
<email>kernel@linuxace.com</email>
</author>
<published>2013-09-01T15:32:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5cffeb8cddf32488fd882cf8a830c4a484463f2e'/>
<id>5cffeb8cddf32488fd882cf8a830c4a484463f2e</id>
<content type='text'>
commit 1205e1fa615805c9efa97303b552cf445965752a upstream.

In commit b396966c4 (netfilter: xt_TCPMSS: Fix missing fragmentation handling),
I attempted to add safe fragment handling to xt_TCPMSS.  However, Andy Padavan
of Project N56U correctly points out that returning XT_CONTINUE in this
function does not work.  The callers (tcpmss_tg[46]) expect to receive a value
of 0 in order to return XT_CONTINUE.

Signed-off-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 1205e1fa615805c9efa97303b552cf445965752a upstream.

In commit b396966c4 (netfilter: xt_TCPMSS: Fix missing fragmentation handling),
I attempted to add safe fragment handling to xt_TCPMSS.  However, Andy Padavan
of Project N56U correctly points out that returning XT_CONTINUE in this
function does not work.  The callers (tcpmss_tg[46]) expect to receive a value
of 0 in order to return XT_CONTINUE.

Signed-off-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_TCPMSS: fix handling of malformed TCP header and options</title>
<updated>2018-02-13T18:32:21+00:00</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2013-07-25T08:37:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=e1737daf2445ad3c1fd7435104a2aa8c96667349'/>
<id>e1737daf2445ad3c1fd7435104a2aa8c96667349</id>
<content type='text'>
commit 71ffe9c77dd7a2b62207953091efa8dafec958dd upstream.

Make sure the packet has enough room for the TCP header and
that it is not malformed.

While at it, store tcph-&gt;doff*4 in a variable, as it is used
several times.

This patch also fixes a possible off by one in case of malformed
TCP options.

Reported-by: Julian Anastasov &lt;ja@ssi.bg&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 71ffe9c77dd7a2b62207953091efa8dafec958dd upstream.

Make sure the packet has enough room for the TCP header and
that it is not malformed.

While at it, store tcph-&gt;doff*4 in a variable, as it is used
several times.

This patch also fixes a possible off by one in case of malformed
TCP options.

Reported-by: Julian Anastasov &lt;ja@ssi.bg&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_TCPMSS: Fix missing fragmentation handling</title>
<updated>2018-02-13T18:32:21+00:00</updated>
<author>
<name>Phil Oester</name>
<email>kernel@linuxace.com</email>
</author>
<published>2013-06-12T08:58:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=c8b37154268611691b395e4dd19a3bf1a87d57ef'/>
<id>c8b37154268611691b395e4dd19a3bf1a87d57ef</id>
<content type='text'>
commit b396966c4688522863572927cb30aa874b3ec504 upstream.

Similar to commit bc6bcb59 ("netfilter: xt_TCPOPTSTRIP: fix
possible mangling beyond packet boundary"), add safe fragment
handling to xt_TCPMSS.

Signed-off-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: Change parameters for tcpmss_mangle_packet() as
 done upstream in commit 70d19f805f8c "netfilter: xt_TCPMSS: Fix IPv6 default
 MSS too"]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit b396966c4688522863572927cb30aa874b3ec504 upstream.

Similar to commit bc6bcb59 ("netfilter: xt_TCPOPTSTRIP: fix
possible mangling beyond packet boundary"), add safe fragment
handling to xt_TCPMSS.

Signed-off-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: Change parameters for tcpmss_mangle_packet() as
 done upstream in commit 70d19f805f8c "netfilter: xt_TCPMSS: Fix IPv6 default
 MSS too"]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_TCPOPTSTRIP: don't use tcp_hdr()</title>
<updated>2018-02-13T18:32:21+00:00</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2013-06-10T23:51:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=3cdd962a56dea077e57c82c319c8244bcc01693a'/>
<id>3cdd962a56dea077e57c82c319c8244bcc01693a</id>
<content type='text'>
commit ed82c437320c48a4032492f4a55a7e2c934158b6 upstream.

In (bc6bcb5 netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
packet boundary), the use of tcp_hdr was introduced. However, we
cannot assume that skb-&gt;transport_header is set for non-local packets.

Cc: Florian Westphal &lt;fw@strlen.de&gt;
Reported-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit ed82c437320c48a4032492f4a55a7e2c934158b6 upstream.

In (bc6bcb5 netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
packet boundary), the use of tcp_hdr was introduced. However, we
cannot assume that skb-&gt;transport_header is set for non-local packets.

Cc: Florian Westphal &lt;fw@strlen.de&gt;
Reported-by: Phil Oester &lt;kernel@linuxace.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary</title>
<updated>2018-02-13T18:32:20+00:00</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2013-05-07T01:22:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=24a6ca9612ff55f0608196663f843ee4f52ce28b'/>
<id>24a6ca9612ff55f0608196663f843ee4f52ce28b</id>
<content type='text'>
commit bc6bcb59dd7c184d229f9e86d08aa56059938a4c upstream.

This target assumes that tcph-&gt;doff is well-formed, that may be well
not the case. Add extra sanity checkings to avoid possible crash due
to read/write out of the real packet boundary. After this patch, the
default action on malformed TCP packets is to drop them. Moreover,
fragments are skipped.

Reported-by: Rafal Kupka &lt;rkupka@telemetry.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit bc6bcb59dd7c184d229f9e86d08aa56059938a4c upstream.

This target assumes that tcph-&gt;doff is well-formed, that may be well
not the case. Add extra sanity checkings to avoid possible crash due
to read/write out of the real packet boundary. After this patch, the
default action on malformed TCP packets is to drop them. Moreover,
fragments are skipped.

Reported-by: Rafal Kupka &lt;rkupka@telemetry.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: xt_socket: fix compilation warnings with gcc 4.7</title>
<updated>2017-11-11T13:34:44+00:00</updated>
<author>
<name>Pablo Neira Ayuso</name>
<email>pablo@netfilter.org</email>
</author>
<published>2012-08-29T15:58:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=dc3ff135fa742860da7f17a51a0f9776660067e4'/>
<id>dc3ff135fa742860da7f17a51a0f9776660067e4</id>
<content type='text'>
commit 6703aa74ad1ba2e598bb49a37f7518da1195bacb upstream.

This patch fixes compilation warnings in xt_socket with gcc-4.7.

In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:19: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_match.isra.4’:
include/net/netfilter/nf_tproxy_core.h:75:2: warning: ‘protocol’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:113:5: note: ‘protocol’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:45: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:106:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:9: note: ‘dport’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:16: note: ‘saddr’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:9: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:19: note: ‘daddr’ was declared here

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6703aa74ad1ba2e598bb49a37f7518da1195bacb upstream.

This patch fixes compilation warnings in xt_socket with gcc-4.7.

In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:19: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_match.isra.4’:
include/net/netfilter/nf_tproxy_core.h:75:2: warning: ‘protocol’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:113:5: note: ‘protocol’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:45: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:106:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:9: note: ‘dport’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:16: note: ‘saddr’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:9: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:19: note: ‘daddr’ was declared here

Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipv6: Add rt6_get_cookie() function</title>
<updated>2017-11-11T13:34:32+00:00</updated>
<author>
<name>Martin KaFai Lau</name>
<email>kafai@fb.com</email>
</author>
<published>2015-05-23T03:56:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=22d2b8ef67c6f31540bf8bf141bba5adca231009'/>
<id>22d2b8ef67c6f31540bf8bf141bba5adca231009</id>
<content type='text'>
commit b197df4f0f3782782e9ea8996e91b65ae33e8dd9 upstream.

Instead of doing the rt6-&gt;rt6i_node check whenever we need
to get the route's cookie.  Refactor it into rt6_get_cookie().
It is a prep work to handle FLOWI_FLAG_KNOWN_NH and also
percpu rt6_info later.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Cc: Hannes Frederic Sowa &lt;hannes@stressinduktion.org&gt;
Cc: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Cc: Julian Anastasov &lt;ja@ssi.bg&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop changes in inet6_sk_rx_dst_set(), sctp_v6_get_dst()
 - Adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit b197df4f0f3782782e9ea8996e91b65ae33e8dd9 upstream.

Instead of doing the rt6-&gt;rt6i_node check whenever we need
to get the route's cookie.  Refactor it into rt6_get_cookie().
It is a prep work to handle FLOWI_FLAG_KNOWN_NH and also
percpu rt6_info later.

Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Cc: Hannes Frederic Sowa &lt;hannes@stressinduktion.org&gt;
Cc: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Cc: Julian Anastasov &lt;ja@ssi.bg&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop changes in inet6_sk_rx_dst_set(), sctp_v6_get_dst()
 - Adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: nf_conntrack: fix RCU race in nf_conntrack_find_get</title>
<updated>2017-10-12T14:27:21+00:00</updated>
<author>
<name>Andrey Vagin</name>
<email>avagin@openvz.org</email>
</author>
<published>2014-01-29T18:34:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=cf33a744b388cbf5fdd211a3109cc17e420ef8b4'/>
<id>cf33a744b388cbf5fdd211a3109cc17e420ef8b4</id>
<content type='text'>
commit c6825c0976fa7893692e0e43b09740b419b23c09 upstream.

Lets look at destroy_conntrack:

hlist_nulls_del_rcu(&amp;ct-&gt;tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
...
nf_conntrack_free(ct)
	kmem_cache_free(net-&gt;ct.nf_conntrack_cachep, ct);

net-&gt;ct.nf_conntrack_cachep is created with SLAB_DESTROY_BY_RCU.

The hash is protected by rcu, so readers look up conntracks without
locks.
A conntrack is removed from the hash, but in this moment a few readers
still can use the conntrack. Then this conntrack is released and another
thread creates conntrack with the same address and the equal tuple.
After this a reader starts to validate the conntrack:
* It's not dying, because a new conntrack was created
* nf_ct_tuple_equal() returns true.

But this conntrack is not initialized yet, so it can not be used by two
threads concurrently. In this case BUG_ON may be triggered from
nf_nat_setup_info().

Florian Westphal suggested to check the confirm bit too. I think it's
right.

task 1			task 2			task 3
			nf_conntrack_find_get
			 ____nf_conntrack_find
destroy_conntrack
 hlist_nulls_del_rcu
 nf_conntrack_free
 kmem_cache_free
						__nf_conntrack_alloc
						 kmem_cache_alloc
						 memset(&amp;ct-&gt;tuplehash[IP_CT_DIR_MAX],
			 if (nf_ct_is_dying(ct))
			 if (!nf_ct_tuple_equal()

I'm not sure, that I have ever seen this race condition in a real life.
Currently we are investigating a bug, which is reproduced on a few nodes.
In our case one conntrack is initialized from a few tasks concurrently,
we don't have any other explanation for this.

&lt;2&gt;[46267.083061] kernel BUG at net/ipv4/netfilter/nf_nat_core.c:322!
...
&lt;4&gt;[46267.083951] RIP: 0010:[&lt;ffffffffa01e00a4&gt;]  [&lt;ffffffffa01e00a4&gt;] nf_nat_setup_info+0x564/0x590 [nf_nat]
...
&lt;4&gt;[46267.085549] Call Trace:
&lt;4&gt;[46267.085622]  [&lt;ffffffffa023421b&gt;] alloc_null_binding+0x5b/0xa0 [iptable_nat]
&lt;4&gt;[46267.085697]  [&lt;ffffffffa02342bc&gt;] nf_nat_rule_find+0x5c/0x80 [iptable_nat]
&lt;4&gt;[46267.085770]  [&lt;ffffffffa0234521&gt;] nf_nat_fn+0x111/0x260 [iptable_nat]
&lt;4&gt;[46267.085843]  [&lt;ffffffffa0234798&gt;] nf_nat_out+0x48/0xd0 [iptable_nat]
&lt;4&gt;[46267.085919]  [&lt;ffffffff814841b9&gt;] nf_iterate+0x69/0xb0
&lt;4&gt;[46267.085991]  [&lt;ffffffff81494e70&gt;] ? ip_finish_output+0x0/0x2f0
&lt;4&gt;[46267.086063]  [&lt;ffffffff81484374&gt;] nf_hook_slow+0x74/0x110
&lt;4&gt;[46267.086133]  [&lt;ffffffff81494e70&gt;] ? ip_finish_output+0x0/0x2f0
&lt;4&gt;[46267.086207]  [&lt;ffffffff814b5890&gt;] ? dst_output+0x0/0x20
&lt;4&gt;[46267.086277]  [&lt;ffffffff81495204&gt;] ip_output+0xa4/0xc0
&lt;4&gt;[46267.086346]  [&lt;ffffffff814b65a4&gt;] raw_sendmsg+0x8b4/0x910
&lt;4&gt;[46267.086419]  [&lt;ffffffff814c10fa&gt;] inet_sendmsg+0x4a/0xb0
&lt;4&gt;[46267.086491]  [&lt;ffffffff814459aa&gt;] ? sock_update_classid+0x3a/0x50
&lt;4&gt;[46267.086562]  [&lt;ffffffff81444d67&gt;] sock_sendmsg+0x117/0x140
&lt;4&gt;[46267.086638]  [&lt;ffffffff8151997b&gt;] ? _spin_unlock_bh+0x1b/0x20
&lt;4&gt;[46267.086712]  [&lt;ffffffff8109d370&gt;] ? autoremove_wake_function+0x0/0x40
&lt;4&gt;[46267.086785]  [&lt;ffffffff81495e80&gt;] ? do_ip_setsockopt+0x90/0xd80
&lt;4&gt;[46267.086858]  [&lt;ffffffff8100be0e&gt;] ? call_function_interrupt+0xe/0x20
&lt;4&gt;[46267.086936]  [&lt;ffffffff8118cb10&gt;] ? ub_slab_ptr+0x20/0x90
&lt;4&gt;[46267.087006]  [&lt;ffffffff8118cb10&gt;] ? ub_slab_ptr+0x20/0x90
&lt;4&gt;[46267.087081]  [&lt;ffffffff8118f2e8&gt;] ? kmem_cache_alloc+0xd8/0x1e0
&lt;4&gt;[46267.087151]  [&lt;ffffffff81445599&gt;] sys_sendto+0x139/0x190
&lt;4&gt;[46267.087229]  [&lt;ffffffff81448c0d&gt;] ? sock_setsockopt+0x16d/0x6f0
&lt;4&gt;[46267.087303]  [&lt;ffffffff810efa47&gt;] ? audit_syscall_entry+0x1d7/0x200
&lt;4&gt;[46267.087378]  [&lt;ffffffff810ef795&gt;] ? __audit_syscall_exit+0x265/0x290
&lt;4&gt;[46267.087454]  [&lt;ffffffff81474885&gt;] ? compat_sys_setsockopt+0x75/0x210
&lt;4&gt;[46267.087531]  [&lt;ffffffff81474b5f&gt;] compat_sys_socketcall+0x13f/0x210
&lt;4&gt;[46267.087607]  [&lt;ffffffff8104dea3&gt;] ia32_sysret+0x0/0x5
&lt;4&gt;[46267.087676] Code: 91 20 e2 01 75 29 48 89 de 4c 89 f7 e8 56 fa ff ff 85 c0 0f 84 68 fc ff ff 0f b6 4d c6 41 8b 45 00 e9 4d fb ff ff e8 7c 19 e9 e0 &lt;0f&gt; 0b eb fe f6 05 17 91 20 e2 80 74 ce 80 3d 5f 2e 00 00 00 74
&lt;1&gt;[46267.088023] RIP  [&lt;ffffffffa01e00a4&gt;] nf_nat_setup_info+0x564/0x590

Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Florian Westphal &lt;fw@strlen.de&gt;
Cc: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Cc: Patrick McHardy &lt;kaber@trash.net&gt;
Cc: Jozsef Kadlecsik &lt;kadlec@blackhole.kfki.hu&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;
Signed-off-by: Andrey Vagin &lt;avagin@openvz.org&gt;
Acked-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit c6825c0976fa7893692e0e43b09740b419b23c09 upstream.

Lets look at destroy_conntrack:

hlist_nulls_del_rcu(&amp;ct-&gt;tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
...
nf_conntrack_free(ct)
	kmem_cache_free(net-&gt;ct.nf_conntrack_cachep, ct);

net-&gt;ct.nf_conntrack_cachep is created with SLAB_DESTROY_BY_RCU.

The hash is protected by rcu, so readers look up conntracks without
locks.
A conntrack is removed from the hash, but in this moment a few readers
still can use the conntrack. Then this conntrack is released and another
thread creates conntrack with the same address and the equal tuple.
After this a reader starts to validate the conntrack:
* It's not dying, because a new conntrack was created
* nf_ct_tuple_equal() returns true.

But this conntrack is not initialized yet, so it can not be used by two
threads concurrently. In this case BUG_ON may be triggered from
nf_nat_setup_info().

Florian Westphal suggested to check the confirm bit too. I think it's
right.

task 1			task 2			task 3
			nf_conntrack_find_get
			 ____nf_conntrack_find
destroy_conntrack
 hlist_nulls_del_rcu
 nf_conntrack_free
 kmem_cache_free
						__nf_conntrack_alloc
						 kmem_cache_alloc
						 memset(&amp;ct-&gt;tuplehash[IP_CT_DIR_MAX],
			 if (nf_ct_is_dying(ct))
			 if (!nf_ct_tuple_equal()

I'm not sure, that I have ever seen this race condition in a real life.
Currently we are investigating a bug, which is reproduced on a few nodes.
In our case one conntrack is initialized from a few tasks concurrently,
we don't have any other explanation for this.

&lt;2&gt;[46267.083061] kernel BUG at net/ipv4/netfilter/nf_nat_core.c:322!
...
&lt;4&gt;[46267.083951] RIP: 0010:[&lt;ffffffffa01e00a4&gt;]  [&lt;ffffffffa01e00a4&gt;] nf_nat_setup_info+0x564/0x590 [nf_nat]
...
&lt;4&gt;[46267.085549] Call Trace:
&lt;4&gt;[46267.085622]  [&lt;ffffffffa023421b&gt;] alloc_null_binding+0x5b/0xa0 [iptable_nat]
&lt;4&gt;[46267.085697]  [&lt;ffffffffa02342bc&gt;] nf_nat_rule_find+0x5c/0x80 [iptable_nat]
&lt;4&gt;[46267.085770]  [&lt;ffffffffa0234521&gt;] nf_nat_fn+0x111/0x260 [iptable_nat]
&lt;4&gt;[46267.085843]  [&lt;ffffffffa0234798&gt;] nf_nat_out+0x48/0xd0 [iptable_nat]
&lt;4&gt;[46267.085919]  [&lt;ffffffff814841b9&gt;] nf_iterate+0x69/0xb0
&lt;4&gt;[46267.085991]  [&lt;ffffffff81494e70&gt;] ? ip_finish_output+0x0/0x2f0
&lt;4&gt;[46267.086063]  [&lt;ffffffff81484374&gt;] nf_hook_slow+0x74/0x110
&lt;4&gt;[46267.086133]  [&lt;ffffffff81494e70&gt;] ? ip_finish_output+0x0/0x2f0
&lt;4&gt;[46267.086207]  [&lt;ffffffff814b5890&gt;] ? dst_output+0x0/0x20
&lt;4&gt;[46267.086277]  [&lt;ffffffff81495204&gt;] ip_output+0xa4/0xc0
&lt;4&gt;[46267.086346]  [&lt;ffffffff814b65a4&gt;] raw_sendmsg+0x8b4/0x910
&lt;4&gt;[46267.086419]  [&lt;ffffffff814c10fa&gt;] inet_sendmsg+0x4a/0xb0
&lt;4&gt;[46267.086491]  [&lt;ffffffff814459aa&gt;] ? sock_update_classid+0x3a/0x50
&lt;4&gt;[46267.086562]  [&lt;ffffffff81444d67&gt;] sock_sendmsg+0x117/0x140
&lt;4&gt;[46267.086638]  [&lt;ffffffff8151997b&gt;] ? _spin_unlock_bh+0x1b/0x20
&lt;4&gt;[46267.086712]  [&lt;ffffffff8109d370&gt;] ? autoremove_wake_function+0x0/0x40
&lt;4&gt;[46267.086785]  [&lt;ffffffff81495e80&gt;] ? do_ip_setsockopt+0x90/0xd80
&lt;4&gt;[46267.086858]  [&lt;ffffffff8100be0e&gt;] ? call_function_interrupt+0xe/0x20
&lt;4&gt;[46267.086936]  [&lt;ffffffff8118cb10&gt;] ? ub_slab_ptr+0x20/0x90
&lt;4&gt;[46267.087006]  [&lt;ffffffff8118cb10&gt;] ? ub_slab_ptr+0x20/0x90
&lt;4&gt;[46267.087081]  [&lt;ffffffff8118f2e8&gt;] ? kmem_cache_alloc+0xd8/0x1e0
&lt;4&gt;[46267.087151]  [&lt;ffffffff81445599&gt;] sys_sendto+0x139/0x190
&lt;4&gt;[46267.087229]  [&lt;ffffffff81448c0d&gt;] ? sock_setsockopt+0x16d/0x6f0
&lt;4&gt;[46267.087303]  [&lt;ffffffff810efa47&gt;] ? audit_syscall_entry+0x1d7/0x200
&lt;4&gt;[46267.087378]  [&lt;ffffffff810ef795&gt;] ? __audit_syscall_exit+0x265/0x290
&lt;4&gt;[46267.087454]  [&lt;ffffffff81474885&gt;] ? compat_sys_setsockopt+0x75/0x210
&lt;4&gt;[46267.087531]  [&lt;ffffffff81474b5f&gt;] compat_sys_socketcall+0x13f/0x210
&lt;4&gt;[46267.087607]  [&lt;ffffffff8104dea3&gt;] ia32_sysret+0x0/0x5
&lt;4&gt;[46267.087676] Code: 91 20 e2 01 75 29 48 89 de 4c 89 f7 e8 56 fa ff ff 85 c0 0f 84 68 fc ff ff 0f b6 4d c6 41 8b 45 00 e9 4d fb ff ff e8 7c 19 e9 e0 &lt;0f&gt; 0b eb fe f6 05 17 91 20 e2 80 74 ce 80 3d 5f 2e 00 00 00 74
&lt;1&gt;[46267.088023] RIP  [&lt;ffffffffa01e00a4&gt;] nf_nat_setup_info+0x564/0x590

Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Florian Westphal &lt;fw@strlen.de&gt;
Cc: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Cc: Patrick McHardy &lt;kaber@trash.net&gt;
Cc: Jozsef Kadlecsik &lt;kadlec@blackhole.kfki.hu&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;
Signed-off-by: Andrey Vagin &lt;avagin@openvz.org&gt;
Acked-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>netfilter: ctnetlink: fix incorrect nf_ct_put during hash resize</title>
<updated>2017-09-15T17:30:48+00:00</updated>
<author>
<name>Liping Zhang</name>
<email>zlpnobody@gmail.com</email>
</author>
<published>2017-05-20T23:22:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=559211ac7b05b3165cc572f936c1fb82bfdb1fc9'/>
<id>559211ac7b05b3165cc572f936c1fb82bfdb1fc9</id>
<content type='text'>
commit fefa92679dbe0c613e62b6c27235dcfbe9640ad1 upstream.

If nf_conntrack_htable_size was adjusted by the user during the ct
dump operation, we may invoke nf_ct_put twice for the same ct, i.e.
the "last" ct. This will cause the ct will be freed but still linked
in hash buckets.

It's very easy to reproduce the problem by the following commands:
  # while : ; do
  echo $RANDOM &gt; /proc/sys/net/netfilter/nf_conntrack_buckets
  done
  # while : ; do
  conntrack -L
  done
  # iperf -s 127.0.0.1 &amp;
  # iperf -c 127.0.0.1 -P 60 -t 36000

After a while, the system will hang like this:
  NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [bash:20184]
  NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [iperf:20382]
  ...

So at last if we find cb-&gt;args[1] is equal to "last", this means hash
resize happened, then we can set cb-&gt;args[1] to 0 to fix the above
issue.

Fixes: d205dc40798d ("[NETFILTER]: ctnetlink: fix deadlock in table dumping")
Signed-off-by: Liping Zhang &lt;zlpnobody@gmail.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit fefa92679dbe0c613e62b6c27235dcfbe9640ad1 upstream.

If nf_conntrack_htable_size was adjusted by the user during the ct
dump operation, we may invoke nf_ct_put twice for the same ct, i.e.
the "last" ct. This will cause the ct will be freed but still linked
in hash buckets.

It's very easy to reproduce the problem by the following commands:
  # while : ; do
  echo $RANDOM &gt; /proc/sys/net/netfilter/nf_conntrack_buckets
  done
  # while : ; do
  conntrack -L
  done
  # iperf -s 127.0.0.1 &amp;
  # iperf -c 127.0.0.1 -P 60 -t 36000

After a while, the system will hang like this:
  NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [bash:20184]
  NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [iperf:20382]
  ...

So at last if we find cb-&gt;args[1] is equal to "last", this means hash
resize happened, then we can set cb-&gt;args[1] to 0 to fix the above
issue.

Fixes: d205dc40798d ("[NETFILTER]: ctnetlink: fix deadlock in table dumping")
Signed-off-by: Liping Zhang &lt;zlpnobody@gmail.com&gt;
Signed-off-by: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
</feed>
