<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/net/l2tp, branch v3.2.94</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv</title>
<updated>2017-10-12T14:27:20+00:00</updated>
<author>
<name>Paul Hüber</name>
<email>phueber@kernsp.in</email>
</author>
<published>2017-02-26T16:58:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=3a45ed9afc5d3f009e8358ae01a8360c70ae6e32'/>
<id>3a45ed9afc5d3f009e8358ae01a8360c70ae6e32</id>
<content type='text'>
commit 51fb60eb162ab84c5edf2ae9c63cf0b878e5547e upstream.

l2tp_ip_backlog_recv may not return -1 if the packet gets dropped.
The return value is passed up to ip_local_deliver_finish, which treats
negative values as an IP protocol number for resubmission.

Signed-off-by: Paul Hüber &lt;phueber@kernsp.in&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 51fb60eb162ab84c5edf2ae9c63cf0b878e5547e upstream.

l2tp_ip_backlog_recv may not return -1 if the packet gets dropped.
The return value is passed up to ip_local_deliver_finish, which treats
negative values as an IP protocol number for resubmission.

Signed-off-by: Paul Hüber &lt;phueber@kernsp.in&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: don't mask errors in pppol2tp_getsockopt()</title>
<updated>2017-07-18T17:38:42+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-04-06T16:31:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=34b5dcc50abe6445aae34c7d055d70832a5951a7'/>
<id>34b5dcc50abe6445aae34c7d055d70832a5951a7</id>
<content type='text'>
commit 321a52a39189d5e4af542f7dcdc07bba4545cf5d upstream.

pppol2tp_getsockopt() doesn't take into account the error code returned
by pppol2tp_tunnel_getsockopt() or pppol2tp_session_getsockopt(). If
error occurs there, pppol2tp_getsockopt() continues unconditionally and
reports erroneous values.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 321a52a39189d5e4af542f7dcdc07bba4545cf5d upstream.

pppol2tp_getsockopt() doesn't take into account the error code returned
by pppol2tp_tunnel_getsockopt() or pppol2tp_session_getsockopt(). If
error occurs there, pppol2tp_getsockopt() continues unconditionally and
reports erroneous values.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: don't mask errors in pppol2tp_setsockopt()</title>
<updated>2017-07-18T17:38:41+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-04-06T16:31:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7fa07017833f62c0c27e4ca15ab7a43b9dd71b15'/>
<id>7fa07017833f62c0c27e4ca15ab7a43b9dd71b15</id>
<content type='text'>
commit 364700cf8fd54f54ad08313464105a414e3bccb7 upstream.

pppol2tp_setsockopt() unconditionally overwrites the error value
returned by pppol2tp_tunnel_setsockopt() or
pppol2tp_session_setsockopt(), thus hiding errors from userspace.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 364700cf8fd54f54ad08313464105a414e3bccb7 upstream.

pppol2tp_setsockopt() unconditionally overwrites the error value
returned by pppol2tp_tunnel_setsockopt() or
pppol2tp_session_setsockopt(), thus hiding errors from userspace.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: take reference on sessions being dumped</title>
<updated>2017-07-18T17:38:41+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-04-03T10:03:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2b846c841db527fe9afff23b70c265b1809cd792'/>
<id>2b846c841db527fe9afff23b70c265b1809cd792</id>
<content type='text'>
commit e08293a4ccbcc993ded0fdc46f1e57926b833d63 upstream.

Take a reference on the sessions returned by l2tp_session_find_nth()
(and rename it l2tp_session_get_nth() to reflect this change), so that
caller is assured that the session isn't going to disappear while
processing it.

For procfs and debugfs handlers, the session is held in the .start()
callback and dropped in .show(). Given that pppol2tp_seq_session_show()
dereferences the associated PPPoL2TP socket and that
l2tp_dfs_seq_session_show() might call pppol2tp_show(), we also need to
call the session's .ref() callback to prevent the socket from going
away from under us.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Fixes: 0ad6614048cf ("l2tp: Add debugfs files for dumping l2tp debug info")
Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 e08293a4ccbcc993ded0fdc46f1e57926b833d63 upstream.

Take a reference on the sessions returned by l2tp_session_find_nth()
(and rename it l2tp_session_get_nth() to reflect this change), so that
caller is assured that the session isn't going to disappear while
processing it.

For procfs and debugfs handlers, the session is held in the .start()
callback and dropped in .show(). Given that pppol2tp_seq_session_show()
dereferences the associated PPPoL2TP socket and that
l2tp_dfs_seq_session_show() might call pppol2tp_show(), we also need to
call the session's .ref() callback to prevent the socket from going
away from under us.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Fixes: 0ad6614048cf ("l2tp: Add debugfs files for dumping l2tp debug info")
Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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>l2tp: take a reference on sessions used in genetlink handlers</title>
<updated>2017-07-18T17:38:40+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-03-31T11:02:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0d3ab011f8b0c48bdd3f573cb15ceb492ded4d5d'/>
<id>0d3ab011f8b0c48bdd3f573cb15ceb492ded4d5d</id>
<content type='text'>
commit 2777e2ab5a9cf2b4524486c6db1517a6ded25261 upstream.

Callers of l2tp_nl_session_find() need to hold a reference on the
returned session since there's no guarantee that it isn't going to
disappear from under them.

Relying on the fact that no l2tp netlink message may be processed
concurrently isn't enough: sessions can be deleted by other means
(e.g. by closing the PPPOL2TP socket of a ppp pseudowire).

l2tp_nl_cmd_session_delete() is a bit special: it runs a callback
function that may require a previous call to session-&gt;ref(). In
particular, for ppp pseudowires, the callback is l2tp_session_delete(),
which then calls pppol2tp_session_close() and dereferences the PPPOL2TP
socket. The socket might already be gone at the moment
l2tp_session_delete() calls session-&gt;ref(), so we need to take a
reference during the session lookup. So we need to pass the do_ref
variable down to l2tp_session_get() and l2tp_session_get_by_ifname().

Since all callers have to be updated, l2tp_session_find_by_ifname() and
l2tp_nl_session_find() are renamed to reflect their new behaviour.

Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 2777e2ab5a9cf2b4524486c6db1517a6ded25261 upstream.

Callers of l2tp_nl_session_find() need to hold a reference on the
returned session since there's no guarantee that it isn't going to
disappear from under them.

Relying on the fact that no l2tp netlink message may be processed
concurrently isn't enough: sessions can be deleted by other means
(e.g. by closing the PPPOL2TP socket of a ppp pseudowire).

l2tp_nl_cmd_session_delete() is a bit special: it runs a callback
function that may require a previous call to session-&gt;ref(). In
particular, for ppp pseudowires, the callback is l2tp_session_delete(),
which then calls pppol2tp_session_close() and dereferences the PPPOL2TP
socket. The socket might already be gone at the moment
l2tp_session_delete() calls session-&gt;ref(), so we need to take a
reference during the session lookup. So we need to pass the do_ref
variable down to l2tp_session_get() and l2tp_session_get_by_ifname().

Since all callers have to be updated, l2tp_session_find_by_ifname() and
l2tp_nl_session_find() are renamed to reflect their new behaviour.

Fixes: 309795f4bec2 ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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>l2tp: fix duplicate session creation</title>
<updated>2017-07-18T17:38:40+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-03-31T11:02:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0463e1a532e6cdac4cbea44e87657853dc2b61d3'/>
<id>0463e1a532e6cdac4cbea44e87657853dc2b61d3</id>
<content type='text'>
commit dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086 upstream.

l2tp_session_create() relies on its caller for checking for duplicate
sessions. This is racy since a session can be concurrently inserted
after the caller's verification.

Fix this by letting l2tp_session_create() verify sessions uniqueness
upon insertion. Callers need to be adapted to check for
l2tp_session_create()'s return code instead of calling
l2tp_session_find().

pppol2tp_connect() is a bit special because it has to work on existing
sessions (if they're not connected) or to create a new session if none
is found. When acting on a preexisting session, a reference must be
held or it could go away on us. So we have to use l2tp_session_get()
instead of l2tp_session_find() and drop the reference before exiting.

Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support")
Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2: add 'pos' parameter to
 hlist_for_each_entry{,_rcu}() calls]
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 dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086 upstream.

l2tp_session_create() relies on its caller for checking for duplicate
sessions. This is racy since a session can be concurrently inserted
after the caller's verification.

Fix this by letting l2tp_session_create() verify sessions uniqueness
upon insertion. Callers need to be adapted to check for
l2tp_session_create()'s return code instead of calling
l2tp_session_find().

pppol2tp_connect() is a bit special because it has to work on existing
sessions (if they're not connected) or to create a new session if none
is found. When acting on a preexisting session, a reference must be
held or it could go away on us. So we have to use l2tp_session_get()
instead of l2tp_session_find() and drop the reference before exiting.

Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support")
Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2: add 'pos' parameter to
 hlist_for_each_entry{,_rcu}() calls]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: ensure session can't get removed during pppol2tp_session_ioctl()</title>
<updated>2017-07-18T17:38:40+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-03-31T11:02:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a1bf0abb66cf377a70c65dd96cc1dbf662a2a391'/>
<id>a1bf0abb66cf377a70c65dd96cc1dbf662a2a391</id>
<content type='text'>
commit 57377d63547861919ee634b845c7caa38de4a452 upstream.

Holding a reference on session is required before calling
pppol2tp_session_ioctl(). The session could get freed while processing the
ioctl otherwise. Since pppol2tp_session_ioctl() uses the session's socket,
we also need to take a reference on it in l2tp_session_get().

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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 57377d63547861919ee634b845c7caa38de4a452 upstream.

Holding a reference on session is required before calling
pppol2tp_session_ioctl(). The session could get freed while processing the
ioctl otherwise. Since pppol2tp_session_ioctl() uses the session's socket,
we also need to take a reference on it in l2tp_session_get().

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: fix race in l2tp_recv_common()</title>
<updated>2017-07-18T17:38:39+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2017-03-31T11:02:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=63a763d03a6c962c15159081812e67dc9715d9cc'/>
<id>63a763d03a6c962c15159081812e67dc9715d9cc</id>
<content type='text'>
commit 61b9a047729bb230978178bca6729689d0c50ca2 upstream.

Taking a reference on sessions in l2tp_recv_common() is racy; this
has to be done by the callers.

To this end, a new function is required (l2tp_session_get()) to
atomically lookup a session and take a reference on it. Callers then
have to manually drop this reference.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop changes to l2tp_ip6.c
 - Add 'pos' parameter to hlist_for_each_entry{,_rcu}() calls
 - 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 61b9a047729bb230978178bca6729689d0c50ca2 upstream.

Taking a reference on sessions in l2tp_recv_common() is racy; this
has to be done by the callers.

To this end, a new function is required (l2tp_session_get()) to
atomically lookup a session and take a reference on it. Callers then
have to manually drop this reference.

Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop changes to l2tp_ip6.c
 - Add 'pos' parameter to hlist_for_each_entry{,_rcu}() calls
 - Adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: fix racy SOCK_ZAPPED flag check in l2tp_ip{,6}_bind()</title>
<updated>2017-04-04T21:18:32+00:00</updated>
<author>
<name>Guillaume Nault</name>
<email>g.nault@alphalink.fr</email>
</author>
<published>2016-11-18T21:13:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2147a17048314f069838aace1d08b8c719448b50'/>
<id>2147a17048314f069838aace1d08b8c719448b50</id>
<content type='text'>
commit 32c231164b762dddefa13af5a0101032c70b50ef upstream.

Lock socket before checking the SOCK_ZAPPED flag in l2tp_ip6_bind().
Without lock, a concurrent call could modify the socket flags between
the sock_flag(sk, SOCK_ZAPPED) test and the lock_sock() call. This way,
a socket could be inserted twice in l2tp_ip6_bind_table. Releasing it
would then leave a stale pointer there, generating use-after-free
errors when walking through the list or modifying adjacent entries.

BUG: KASAN: use-after-free in l2tp_ip6_close+0x22e/0x290 at addr ffff8800081b0ed8
Write of size 8 by task syz-executor/10987
CPU: 0 PID: 10987 Comm: syz-executor Not tainted 4.8.0+ #39
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
 ffff880031d97838 ffffffff829f835b ffff88001b5a1640 ffff8800081b0ec0
 ffff8800081b15a0 ffff8800081b6d20 ffff880031d97860 ffffffff8174d3cc
 ffff880031d978f0 ffff8800081b0e80 ffff88001b5a1640 ffff880031d978e0
Call Trace:
 [&lt;ffffffff829f835b&gt;] dump_stack+0xb3/0x118 lib/dump_stack.c:15
 [&lt;ffffffff8174d3cc&gt;] kasan_object_err+0x1c/0x70 mm/kasan/report.c:156
 [&lt;     inline     &gt;] print_address_description mm/kasan/report.c:194
 [&lt;ffffffff8174d666&gt;] kasan_report_error+0x1f6/0x4d0 mm/kasan/report.c:283
 [&lt;     inline     &gt;] kasan_report mm/kasan/report.c:303
 [&lt;ffffffff8174db7e&gt;] __asan_report_store8_noabort+0x3e/0x40 mm/kasan/report.c:329
 [&lt;     inline     &gt;] __write_once_size ./include/linux/compiler.h:249
 [&lt;     inline     &gt;] __hlist_del ./include/linux/list.h:622
 [&lt;     inline     &gt;] hlist_del_init ./include/linux/list.h:637
 [&lt;ffffffff8579047e&gt;] l2tp_ip6_close+0x22e/0x290 net/l2tp/l2tp_ip6.c:239
 [&lt;ffffffff850b2dfd&gt;] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
 [&lt;ffffffff851dc5a0&gt;] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
 [&lt;ffffffff84c4581d&gt;] sock_release+0x8d/0x1d0 net/socket.c:570
 [&lt;ffffffff84c45976&gt;] sock_close+0x16/0x20 net/socket.c:1017
 [&lt;ffffffff817a108c&gt;] __fput+0x28c/0x780 fs/file_table.c:208
 [&lt;ffffffff817a1605&gt;] ____fput+0x15/0x20 fs/file_table.c:244
 [&lt;ffffffff813774f9&gt;] task_work_run+0xf9/0x170
 [&lt;ffffffff81324aae&gt;] do_exit+0x85e/0x2a00
 [&lt;ffffffff81326dc8&gt;] do_group_exit+0x108/0x330
 [&lt;ffffffff81348cf7&gt;] get_signal+0x617/0x17a0 kernel/signal.c:2307
 [&lt;ffffffff811b49af&gt;] do_signal+0x7f/0x18f0
 [&lt;ffffffff810039bf&gt;] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
 [&lt;     inline     &gt;] prepare_exit_to_usermode arch/x86/entry/common.c:190
 [&lt;ffffffff81006060&gt;] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
 [&lt;ffffffff85e4d726&gt;] entry_SYSCALL_64_fastpath+0xc4/0xc6
Object at ffff8800081b0ec0, in cache L2TP/IPv6 size: 1448
Allocated:
PID = 10987
 [ 1116.897025] [&lt;ffffffff811ddcb6&gt;] save_stack_trace+0x16/0x20
 [ 1116.897025] [&lt;ffffffff8174c736&gt;] save_stack+0x46/0xd0
 [ 1116.897025] [&lt;ffffffff8174c9ad&gt;] kasan_kmalloc+0xad/0xe0
 [ 1116.897025] [&lt;ffffffff8174cee2&gt;] kasan_slab_alloc+0x12/0x20
 [ 1116.897025] [&lt;     inline     &gt;] slab_post_alloc_hook mm/slab.h:417
 [ 1116.897025] [&lt;     inline     &gt;] slab_alloc_node mm/slub.c:2708
 [ 1116.897025] [&lt;     inline     &gt;] slab_alloc mm/slub.c:2716
 [ 1116.897025] [&lt;ffffffff817476a8&gt;] kmem_cache_alloc+0xc8/0x2b0 mm/slub.c:2721
 [ 1116.897025] [&lt;ffffffff84c4f6a9&gt;] sk_prot_alloc+0x69/0x2b0 net/core/sock.c:1326
 [ 1116.897025] [&lt;ffffffff84c58ac8&gt;] sk_alloc+0x38/0xae0 net/core/sock.c:1388
 [ 1116.897025] [&lt;ffffffff851ddf67&gt;] inet6_create+0x2d7/0x1000 net/ipv6/af_inet6.c:182
 [ 1116.897025] [&lt;ffffffff84c4af7b&gt;] __sock_create+0x37b/0x640 net/socket.c:1153
 [ 1116.897025] [&lt;     inline     &gt;] sock_create net/socket.c:1193
 [ 1116.897025] [&lt;     inline     &gt;] SYSC_socket net/socket.c:1223
 [ 1116.897025] [&lt;ffffffff84c4b46f&gt;] SyS_socket+0xef/0x1b0 net/socket.c:1203
 [ 1116.897025] [&lt;ffffffff85e4d685&gt;] entry_SYSCALL_64_fastpath+0x23/0xc6
Freed:
PID = 10987
 [ 1116.897025] [&lt;ffffffff811ddcb6&gt;] save_stack_trace+0x16/0x20
 [ 1116.897025] [&lt;ffffffff8174c736&gt;] save_stack+0x46/0xd0
 [ 1116.897025] [&lt;ffffffff8174cf61&gt;] kasan_slab_free+0x71/0xb0
 [ 1116.897025] [&lt;     inline     &gt;] slab_free_hook mm/slub.c:1352
 [ 1116.897025] [&lt;     inline     &gt;] slab_free_freelist_hook mm/slub.c:1374
 [ 1116.897025] [&lt;     inline     &gt;] slab_free mm/slub.c:2951
 [ 1116.897025] [&lt;ffffffff81748b28&gt;] kmem_cache_free+0xc8/0x330 mm/slub.c:2973
 [ 1116.897025] [&lt;     inline     &gt;] sk_prot_free net/core/sock.c:1369
 [ 1116.897025] [&lt;ffffffff84c541eb&gt;] __sk_destruct+0x32b/0x4f0 net/core/sock.c:1444
 [ 1116.897025] [&lt;ffffffff84c5aca4&gt;] sk_destruct+0x44/0x80 net/core/sock.c:1452
 [ 1116.897025] [&lt;ffffffff84c5ad33&gt;] __sk_free+0x53/0x220 net/core/sock.c:1460
 [ 1116.897025] [&lt;ffffffff84c5af23&gt;] sk_free+0x23/0x30 net/core/sock.c:1471
 [ 1116.897025] [&lt;ffffffff84c5cb6c&gt;] sk_common_release+0x28c/0x3e0 ./include/net/sock.h:1589
 [ 1116.897025] [&lt;ffffffff8579044e&gt;] l2tp_ip6_close+0x1fe/0x290 net/l2tp/l2tp_ip6.c:243
 [ 1116.897025] [&lt;ffffffff850b2dfd&gt;] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
 [ 1116.897025] [&lt;ffffffff851dc5a0&gt;] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
 [ 1116.897025] [&lt;ffffffff84c4581d&gt;] sock_release+0x8d/0x1d0 net/socket.c:570
 [ 1116.897025] [&lt;ffffffff84c45976&gt;] sock_close+0x16/0x20 net/socket.c:1017
 [ 1116.897025] [&lt;ffffffff817a108c&gt;] __fput+0x28c/0x780 fs/file_table.c:208
 [ 1116.897025] [&lt;ffffffff817a1605&gt;] ____fput+0x15/0x20 fs/file_table.c:244
 [ 1116.897025] [&lt;ffffffff813774f9&gt;] task_work_run+0xf9/0x170
 [ 1116.897025] [&lt;ffffffff81324aae&gt;] do_exit+0x85e/0x2a00
 [ 1116.897025] [&lt;ffffffff81326dc8&gt;] do_group_exit+0x108/0x330
 [ 1116.897025] [&lt;ffffffff81348cf7&gt;] get_signal+0x617/0x17a0 kernel/signal.c:2307
 [ 1116.897025] [&lt;ffffffff811b49af&gt;] do_signal+0x7f/0x18f0
 [ 1116.897025] [&lt;ffffffff810039bf&gt;] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
 [ 1116.897025] [&lt;     inline     &gt;] prepare_exit_to_usermode arch/x86/entry/common.c:190
 [ 1116.897025] [&lt;ffffffff81006060&gt;] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
 [ 1116.897025] [&lt;ffffffff85e4d726&gt;] entry_SYSCALL_64_fastpath+0xc4/0xc6
Memory state around the buggy address:
 ffff8800081b0d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8800081b0e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt;ffff8800081b0e80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                    ^
 ffff8800081b0f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8800081b0f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

==================================================================

The same issue exists with l2tp_ip_bind() and l2tp_ip_bind_table.

Fixes: c51ce49735c1 ("l2tp: fix oops in L2TP IP sockets for connect() AF_UNSPEC case")
Reported-by: Baozeng Ding &lt;sploving1@gmail.com&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Tested-by: Baozeng Ding &lt;sploving1@gmail.com&gt;
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2: drop IPv6 changes]
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 32c231164b762dddefa13af5a0101032c70b50ef upstream.

Lock socket before checking the SOCK_ZAPPED flag in l2tp_ip6_bind().
Without lock, a concurrent call could modify the socket flags between
the sock_flag(sk, SOCK_ZAPPED) test and the lock_sock() call. This way,
a socket could be inserted twice in l2tp_ip6_bind_table. Releasing it
would then leave a stale pointer there, generating use-after-free
errors when walking through the list or modifying adjacent entries.

BUG: KASAN: use-after-free in l2tp_ip6_close+0x22e/0x290 at addr ffff8800081b0ed8
Write of size 8 by task syz-executor/10987
CPU: 0 PID: 10987 Comm: syz-executor Not tainted 4.8.0+ #39
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
 ffff880031d97838 ffffffff829f835b ffff88001b5a1640 ffff8800081b0ec0
 ffff8800081b15a0 ffff8800081b6d20 ffff880031d97860 ffffffff8174d3cc
 ffff880031d978f0 ffff8800081b0e80 ffff88001b5a1640 ffff880031d978e0
Call Trace:
 [&lt;ffffffff829f835b&gt;] dump_stack+0xb3/0x118 lib/dump_stack.c:15
 [&lt;ffffffff8174d3cc&gt;] kasan_object_err+0x1c/0x70 mm/kasan/report.c:156
 [&lt;     inline     &gt;] print_address_description mm/kasan/report.c:194
 [&lt;ffffffff8174d666&gt;] kasan_report_error+0x1f6/0x4d0 mm/kasan/report.c:283
 [&lt;     inline     &gt;] kasan_report mm/kasan/report.c:303
 [&lt;ffffffff8174db7e&gt;] __asan_report_store8_noabort+0x3e/0x40 mm/kasan/report.c:329
 [&lt;     inline     &gt;] __write_once_size ./include/linux/compiler.h:249
 [&lt;     inline     &gt;] __hlist_del ./include/linux/list.h:622
 [&lt;     inline     &gt;] hlist_del_init ./include/linux/list.h:637
 [&lt;ffffffff8579047e&gt;] l2tp_ip6_close+0x22e/0x290 net/l2tp/l2tp_ip6.c:239
 [&lt;ffffffff850b2dfd&gt;] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
 [&lt;ffffffff851dc5a0&gt;] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
 [&lt;ffffffff84c4581d&gt;] sock_release+0x8d/0x1d0 net/socket.c:570
 [&lt;ffffffff84c45976&gt;] sock_close+0x16/0x20 net/socket.c:1017
 [&lt;ffffffff817a108c&gt;] __fput+0x28c/0x780 fs/file_table.c:208
 [&lt;ffffffff817a1605&gt;] ____fput+0x15/0x20 fs/file_table.c:244
 [&lt;ffffffff813774f9&gt;] task_work_run+0xf9/0x170
 [&lt;ffffffff81324aae&gt;] do_exit+0x85e/0x2a00
 [&lt;ffffffff81326dc8&gt;] do_group_exit+0x108/0x330
 [&lt;ffffffff81348cf7&gt;] get_signal+0x617/0x17a0 kernel/signal.c:2307
 [&lt;ffffffff811b49af&gt;] do_signal+0x7f/0x18f0
 [&lt;ffffffff810039bf&gt;] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
 [&lt;     inline     &gt;] prepare_exit_to_usermode arch/x86/entry/common.c:190
 [&lt;ffffffff81006060&gt;] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
 [&lt;ffffffff85e4d726&gt;] entry_SYSCALL_64_fastpath+0xc4/0xc6
Object at ffff8800081b0ec0, in cache L2TP/IPv6 size: 1448
Allocated:
PID = 10987
 [ 1116.897025] [&lt;ffffffff811ddcb6&gt;] save_stack_trace+0x16/0x20
 [ 1116.897025] [&lt;ffffffff8174c736&gt;] save_stack+0x46/0xd0
 [ 1116.897025] [&lt;ffffffff8174c9ad&gt;] kasan_kmalloc+0xad/0xe0
 [ 1116.897025] [&lt;ffffffff8174cee2&gt;] kasan_slab_alloc+0x12/0x20
 [ 1116.897025] [&lt;     inline     &gt;] slab_post_alloc_hook mm/slab.h:417
 [ 1116.897025] [&lt;     inline     &gt;] slab_alloc_node mm/slub.c:2708
 [ 1116.897025] [&lt;     inline     &gt;] slab_alloc mm/slub.c:2716
 [ 1116.897025] [&lt;ffffffff817476a8&gt;] kmem_cache_alloc+0xc8/0x2b0 mm/slub.c:2721
 [ 1116.897025] [&lt;ffffffff84c4f6a9&gt;] sk_prot_alloc+0x69/0x2b0 net/core/sock.c:1326
 [ 1116.897025] [&lt;ffffffff84c58ac8&gt;] sk_alloc+0x38/0xae0 net/core/sock.c:1388
 [ 1116.897025] [&lt;ffffffff851ddf67&gt;] inet6_create+0x2d7/0x1000 net/ipv6/af_inet6.c:182
 [ 1116.897025] [&lt;ffffffff84c4af7b&gt;] __sock_create+0x37b/0x640 net/socket.c:1153
 [ 1116.897025] [&lt;     inline     &gt;] sock_create net/socket.c:1193
 [ 1116.897025] [&lt;     inline     &gt;] SYSC_socket net/socket.c:1223
 [ 1116.897025] [&lt;ffffffff84c4b46f&gt;] SyS_socket+0xef/0x1b0 net/socket.c:1203
 [ 1116.897025] [&lt;ffffffff85e4d685&gt;] entry_SYSCALL_64_fastpath+0x23/0xc6
Freed:
PID = 10987
 [ 1116.897025] [&lt;ffffffff811ddcb6&gt;] save_stack_trace+0x16/0x20
 [ 1116.897025] [&lt;ffffffff8174c736&gt;] save_stack+0x46/0xd0
 [ 1116.897025] [&lt;ffffffff8174cf61&gt;] kasan_slab_free+0x71/0xb0
 [ 1116.897025] [&lt;     inline     &gt;] slab_free_hook mm/slub.c:1352
 [ 1116.897025] [&lt;     inline     &gt;] slab_free_freelist_hook mm/slub.c:1374
 [ 1116.897025] [&lt;     inline     &gt;] slab_free mm/slub.c:2951
 [ 1116.897025] [&lt;ffffffff81748b28&gt;] kmem_cache_free+0xc8/0x330 mm/slub.c:2973
 [ 1116.897025] [&lt;     inline     &gt;] sk_prot_free net/core/sock.c:1369
 [ 1116.897025] [&lt;ffffffff84c541eb&gt;] __sk_destruct+0x32b/0x4f0 net/core/sock.c:1444
 [ 1116.897025] [&lt;ffffffff84c5aca4&gt;] sk_destruct+0x44/0x80 net/core/sock.c:1452
 [ 1116.897025] [&lt;ffffffff84c5ad33&gt;] __sk_free+0x53/0x220 net/core/sock.c:1460
 [ 1116.897025] [&lt;ffffffff84c5af23&gt;] sk_free+0x23/0x30 net/core/sock.c:1471
 [ 1116.897025] [&lt;ffffffff84c5cb6c&gt;] sk_common_release+0x28c/0x3e0 ./include/net/sock.h:1589
 [ 1116.897025] [&lt;ffffffff8579044e&gt;] l2tp_ip6_close+0x1fe/0x290 net/l2tp/l2tp_ip6.c:243
 [ 1116.897025] [&lt;ffffffff850b2dfd&gt;] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
 [ 1116.897025] [&lt;ffffffff851dc5a0&gt;] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
 [ 1116.897025] [&lt;ffffffff84c4581d&gt;] sock_release+0x8d/0x1d0 net/socket.c:570
 [ 1116.897025] [&lt;ffffffff84c45976&gt;] sock_close+0x16/0x20 net/socket.c:1017
 [ 1116.897025] [&lt;ffffffff817a108c&gt;] __fput+0x28c/0x780 fs/file_table.c:208
 [ 1116.897025] [&lt;ffffffff817a1605&gt;] ____fput+0x15/0x20 fs/file_table.c:244
 [ 1116.897025] [&lt;ffffffff813774f9&gt;] task_work_run+0xf9/0x170
 [ 1116.897025] [&lt;ffffffff81324aae&gt;] do_exit+0x85e/0x2a00
 [ 1116.897025] [&lt;ffffffff81326dc8&gt;] do_group_exit+0x108/0x330
 [ 1116.897025] [&lt;ffffffff81348cf7&gt;] get_signal+0x617/0x17a0 kernel/signal.c:2307
 [ 1116.897025] [&lt;ffffffff811b49af&gt;] do_signal+0x7f/0x18f0
 [ 1116.897025] [&lt;ffffffff810039bf&gt;] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
 [ 1116.897025] [&lt;     inline     &gt;] prepare_exit_to_usermode arch/x86/entry/common.c:190
 [ 1116.897025] [&lt;ffffffff81006060&gt;] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
 [ 1116.897025] [&lt;ffffffff85e4d726&gt;] entry_SYSCALL_64_fastpath+0xc4/0xc6
Memory state around the buggy address:
 ffff8800081b0d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8800081b0e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
&gt;ffff8800081b0e80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                    ^
 ffff8800081b0f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8800081b0f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

==================================================================

The same issue exists with l2tp_ip_bind() and l2tp_ip_bind_table.

Fixes: c51ce49735c1 ("l2tp: fix oops in L2TP IP sockets for connect() AF_UNSPEC case")
Reported-by: Baozeng Ding &lt;sploving1@gmail.com&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Tested-by: Baozeng Ding &lt;sploving1@gmail.com&gt;
Signed-off-by: Guillaume Nault &lt;g.nault@alphalink.fr&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2: drop IPv6 changes]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>l2tp: do not use udp_ioctl()</title>
<updated>2017-03-16T02:18:49+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2017-02-10T00:15:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ddd8309bd85c93455b993207dd5209ee937070e9'/>
<id>ddd8309bd85c93455b993207dd5209ee937070e9</id>
<content type='text'>
commit 72fb96e7bdbbdd4421b0726992496531060f3636 upstream.

udp_ioctl(), as its name suggests, is used by UDP protocols,
but is also used by L2TP :(

L2TP should use its own handler, because it really does not
look the same.

SIOCINQ for instance should not assume UDP checksum or headers.

Thanks to Andrey and syzkaller team for providing the report
and a nice reproducer.

While crashes only happen on recent kernels (after commit
7c13f97ffde6 ("udp: do fwd memory scheduling on dequeue")), this
probably needs to be backported to older kernels.

Fixes: 7c13f97ffde6 ("udp: do fwd memory scheduling on dequeue")
Fixes: 85584672012e ("udp: Fix udp_poll() and ioctl()")
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Acked-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop the IPv6 change
 - 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 72fb96e7bdbbdd4421b0726992496531060f3636 upstream.

udp_ioctl(), as its name suggests, is used by UDP protocols,
but is also used by L2TP :(

L2TP should use its own handler, because it really does not
look the same.

SIOCINQ for instance should not assume UDP checksum or headers.

Thanks to Andrey and syzkaller team for providing the report
and a nice reproducer.

While crashes only happen on recent kernels (after commit
7c13f97ffde6 ("udp: do fwd memory scheduling on dequeue")), this
probably needs to be backported to older kernels.

Fixes: 7c13f97ffde6 ("udp: do fwd memory scheduling on dequeue")
Fixes: 85584672012e ("udp: Fix udp_poll() and ioctl()")
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Acked-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to 3.2:
 - Drop the IPv6 change
 - Adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
</feed>
