<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/net/sctp, branch linux-5.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2019-07-28T06:28:31Z</updated>
<entry>
<title>sctp: not bind the socket in sctp_connect</title>
<updated>2019-07-28T06:28:31Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-06-26T08:31:39Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=066992c6328c637384f82a6832016a21fcd3a089'/>
<id>urn:sha1:066992c6328c637384f82a6832016a21fcd3a089</id>
<content type='text'>
[ Upstream commit 9b6c08878e23adb7cc84bdca94d8a944b03f099e ]

Now when sctp_connect() is called with a wrong sa_family, it binds
to a port but doesn't set bp-&gt;port, then sctp_get_af_specific will
return NULL and sctp_connect() returns -EINVAL.

Then if sctp_bind() is called to bind to another port, the last
port it has bound will leak due to bp-&gt;port is NULL by then.

sctp_connect() doesn't need to bind ports, as later __sctp_connect
will do it if bp-&gt;port is NULL. So remove it from sctp_connect().
While at it, remove the unnecessary sockaddr.sa_family len check
as it's already done in sctp_inet_connect.

Fixes: 644fbdeacf1d ("sctp: fix the issue that flags are ignored when using kernel_connect")
Reported-by: syzbot+079bf326b38072f849d9@syzkaller.appspotmail.com
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Acked-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sctp: fix error handling on stream scheduler initialization</title>
<updated>2019-07-28T06:28:31Z</updated>
<author>
<name>Marcelo Ricardo Leitner</name>
<email>marcelo.leitner@gmail.com</email>
</author>
<published>2019-06-27T22:48:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2a8e1d0c9646f78fdd0f00e2eadf8210bbf810a7'/>
<id>urn:sha1:2a8e1d0c9646f78fdd0f00e2eadf8210bbf810a7</id>
<content type='text'>
[ Upstream commit 4d1415811e492d9a8238f8a92dd0d51612c788e9 ]

It allocates the extended area for outbound streams only on sendmsg
calls, if they are not yet allocated.  When using the priority
stream scheduler, this initialization may imply into a subsequent
allocation, which may fail.  In this case, it was aborting the stream
scheduler initialization but leaving the -&gt;ext pointer (allocated) in
there, thus in a partially initialized state.  On a subsequent call to
sendmsg, it would notice the -&gt;ext pointer in there, and trip on
uninitialized stuff when trying to schedule the data chunk.

The fix is undo the -&gt;ext initialization if the stream scheduler
initialization fails and avoid the partially initialized state.

Although syzkaller bisected this to commit 4ff40b86262b ("sctp: set
chunk transport correctly when it's a new asoc"), this bug was actually
introduced on the commit I marked below.

Reported-by: syzbot+c1a380d42b190ad1e559@syzkaller.appspotmail.com
Fixes: 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
Tested-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Signed-off-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sctp: change to hold sk after auth shkey is created successfully</title>
<updated>2019-07-03T11:13:41Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-06-24T16:21:45Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=6c616a135a6d9b8ff2f5aa65b6c0999530228058'/>
<id>urn:sha1:6c616a135a6d9b8ff2f5aa65b6c0999530228058</id>
<content type='text'>
[ Upstream commit 25bff6d5478b2a02368097015b7d8eb727c87e16 ]

Now in sctp_endpoint_init(), it holds the sk then creates auth
shkey. But when the creation fails, it doesn't release the sk,
which causes a sk defcnf leak,

Here to fix it by only holding the sk when auth shkey is created
successfully.

Fixes: a29a5bd4f5c3 ("[SCTP]: Implement SCTP-AUTH initializations.")
Reported-by: syzbot+afabda3890cc2f765041@syzkaller.appspotmail.com
Reported-by: syzbot+276ca1c77a19977c0130@syzkaller.appspotmail.com
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sctp: Free cookie before we memdup a new one</title>
<updated>2019-06-22T06:09:04Z</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2019-06-13T10:35:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9cb8eddfe7d65f6573dc76b64b9edc04aa042db7'/>
<id>urn:sha1:9cb8eddfe7d65f6573dc76b64b9edc04aa042db7</id>
<content type='text'>
[ Upstream commit ce950f1050cece5e406a5cde723c69bba60e1b26 ]

Based on comments from Xin, even after fixes for our recent syzbot
report of cookie memory leaks, its possible to get a resend of an INIT
chunk which would lead to us leaking cookie memory.

To ensure that we don't leak cookie memory, free any previously
allocated cookie first.

Change notes
v1-&gt;v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)

v2-&gt;v3
net-&gt;sctp
also free peer_chunks

v3-&gt;v4
fix subject tags

v4-&gt;v5
remove cut line

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Reported-by: syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.com
CC: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
CC: Xin Long &lt;lucien.xin@gmail.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: netdev@vger.kernel.org
Acked-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Fix memory leak in sctp_process_init</title>
<updated>2019-06-11T10:19:09Z</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2019-06-03T20:32:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=8bcd52096232d83be1beddecd621a9b8aee08c88'/>
<id>urn:sha1:8bcd52096232d83be1beddecd621a9b8aee08c88</id>
<content type='text'>
[ Upstream commit 0a8dd9f67cd0da7dc284f48b032ce00db1a68791 ]

syzbot found the following leak in sctp_process_init
BUG: memory leak
unreferenced object 0xffff88810ef68400 (size 1024):
  comm "syz-executor273", pid 7046, jiffies 4294945598 (age 28.770s)
  hex dump (first 32 bytes):
    1d de 28 8d de 0b 1b e3 b5 c2 f9 68 fd 1a 97 25  ..(........h...%
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;00000000a02cebbd&gt;] kmemleak_alloc_recursive include/linux/kmemleak.h:55
[inline]
    [&lt;00000000a02cebbd&gt;] slab_post_alloc_hook mm/slab.h:439 [inline]
    [&lt;00000000a02cebbd&gt;] slab_alloc mm/slab.c:3326 [inline]
    [&lt;00000000a02cebbd&gt;] __do_kmalloc mm/slab.c:3658 [inline]
    [&lt;00000000a02cebbd&gt;] __kmalloc_track_caller+0x15d/0x2c0 mm/slab.c:3675
    [&lt;000000009e6245e6&gt;] kmemdup+0x27/0x60 mm/util.c:119
    [&lt;00000000dfdc5d2d&gt;] kmemdup include/linux/string.h:432 [inline]
    [&lt;00000000dfdc5d2d&gt;] sctp_process_init+0xa7e/0xc20
net/sctp/sm_make_chunk.c:2437
    [&lt;00000000b58b62f8&gt;] sctp_cmd_process_init net/sctp/sm_sideeffect.c:682
[inline]
    [&lt;00000000b58b62f8&gt;] sctp_cmd_interpreter net/sctp/sm_sideeffect.c:1384
[inline]
    [&lt;00000000b58b62f8&gt;] sctp_side_effects net/sctp/sm_sideeffect.c:1194
[inline]
    [&lt;00000000b58b62f8&gt;] sctp_do_sm+0xbdc/0x1d60 net/sctp/sm_sideeffect.c:1165
    [&lt;0000000044e11f96&gt;] sctp_assoc_bh_rcv+0x13c/0x200
net/sctp/associola.c:1074
    [&lt;00000000ec43804d&gt;] sctp_inq_push+0x7f/0xb0 net/sctp/inqueue.c:95
    [&lt;00000000726aa954&gt;] sctp_backlog_rcv+0x5e/0x2a0 net/sctp/input.c:354
    [&lt;00000000d9e249a8&gt;] sk_backlog_rcv include/net/sock.h:950 [inline]
    [&lt;00000000d9e249a8&gt;] __release_sock+0xab/0x110 net/core/sock.c:2418
    [&lt;00000000acae44fa&gt;] release_sock+0x37/0xd0 net/core/sock.c:2934
    [&lt;00000000963cc9ae&gt;] sctp_sendmsg+0x2c0/0x990 net/sctp/socket.c:2122
    [&lt;00000000a7fc7565&gt;] inet_sendmsg+0x64/0x120 net/ipv4/af_inet.c:802
    [&lt;00000000b732cbd3&gt;] sock_sendmsg_nosec net/socket.c:652 [inline]
    [&lt;00000000b732cbd3&gt;] sock_sendmsg+0x54/0x70 net/socket.c:671
    [&lt;00000000274c57ab&gt;] ___sys_sendmsg+0x393/0x3c0 net/socket.c:2292
    [&lt;000000008252aedb&gt;] __sys_sendmsg+0x80/0xf0 net/socket.c:2330
    [&lt;00000000f7bf23d1&gt;] __do_sys_sendmsg net/socket.c:2339 [inline]
    [&lt;00000000f7bf23d1&gt;] __se_sys_sendmsg net/socket.c:2337 [inline]
    [&lt;00000000f7bf23d1&gt;] __x64_sys_sendmsg+0x23/0x30 net/socket.c:2337
    [&lt;00000000a8b4131f&gt;] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:3

The problem was that the peer.cookie value points to an skb allocated
area on the first pass through this function, at which point it is
overwritten with a heap allocated value, but in certain cases, where a
COOKIE_ECHO chunk is included in the packet, a second pass through
sctp_process_init is made, where the cookie value is re-allocated,
leaking the first allocation.

Fix is to always allocate the cookie value, and free it when we are done
using it.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Reported-by: syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.com
CC: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
CC: "David S. Miller" &lt;davem@davemloft.net&gt;
CC: netdev@vger.kernel.org
Acked-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sctp: avoid running the sctp state machine recursively</title>
<updated>2019-05-01T13:18:57Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-04-29T06:16:19Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=fbd019737d71e405f86549fd738f81e2ff3dd073'/>
<id>urn:sha1:fbd019737d71e405f86549fd738f81e2ff3dd073</id>
<content type='text'>
Ying triggered a call trace when doing an asconf testing:

  BUG: scheduling while atomic: swapper/12/0/0x10000100
  Call Trace:
   &lt;IRQ&gt;  [&lt;ffffffffa4375904&gt;] dump_stack+0x19/0x1b
   [&lt;ffffffffa436fcaf&gt;] __schedule_bug+0x64/0x72
   [&lt;ffffffffa437b93a&gt;] __schedule+0x9ba/0xa00
   [&lt;ffffffffa3cd5326&gt;] __cond_resched+0x26/0x30
   [&lt;ffffffffa437bc4a&gt;] _cond_resched+0x3a/0x50
   [&lt;ffffffffa3e22be8&gt;] kmem_cache_alloc_node+0x38/0x200
   [&lt;ffffffffa423512d&gt;] __alloc_skb+0x5d/0x2d0
   [&lt;ffffffffc0995320&gt;] sctp_packet_transmit+0x610/0xa20 [sctp]
   [&lt;ffffffffc098510e&gt;] sctp_outq_flush+0x2ce/0xc00 [sctp]
   [&lt;ffffffffc098646c&gt;] sctp_outq_uncork+0x1c/0x20 [sctp]
   [&lt;ffffffffc0977338&gt;] sctp_cmd_interpreter.isra.22+0xc8/0x1460 [sctp]
   [&lt;ffffffffc0976ad1&gt;] sctp_do_sm+0xe1/0x350 [sctp]
   [&lt;ffffffffc099443d&gt;] sctp_primitive_ASCONF+0x3d/0x50 [sctp]
   [&lt;ffffffffc0977384&gt;] sctp_cmd_interpreter.isra.22+0x114/0x1460 [sctp]
   [&lt;ffffffffc0976ad1&gt;] sctp_do_sm+0xe1/0x350 [sctp]
   [&lt;ffffffffc097b3a4&gt;] sctp_assoc_bh_rcv+0xf4/0x1b0 [sctp]
   [&lt;ffffffffc09840f1&gt;] sctp_inq_push+0x51/0x70 [sctp]
   [&lt;ffffffffc099732b&gt;] sctp_rcv+0xa8b/0xbd0 [sctp]

As it shows, the first sctp_do_sm() running under atomic context (NET_RX
softirq) invoked sctp_primitive_ASCONF() that uses GFP_KERNEL flag later,
and this flag is supposed to be used in non-atomic context only. Besides,
sctp_do_sm() was called recursively, which is not expected.

Vlad tried to fix this recursive call in Commit c0786693404c ("sctp: Fix
oops when sending queued ASCONF chunks") by introducing a new command
SCTP_CMD_SEND_NEXT_ASCONF. But it didn't work as this command is still
used in the first sctp_do_sm() call, and sctp_primitive_ASCONF() will
be called in this command again.

To avoid calling sctp_do_sm() recursively, we send the next queued ASCONF
not by sctp_primitive_ASCONF(), but by sctp_sf_do_prm_asconf() in the 1st
sctp_do_sm() directly.

Reported-by: Ying Xu &lt;yinxu@redhat.com&gt;
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: Check address length before reading address family</title>
<updated>2019-04-12T17:25:03Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@I-love.SAKURA.ne.jp</email>
</author>
<published>2019-04-12T10:53:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=175f7c1f01d30b2088491bee4636fbf846fb76ce'/>
<id>urn:sha1:175f7c1f01d30b2088491bee4636fbf846fb76ce</id>
<content type='text'>
KMSAN will complain if valid address length passed to connect() is shorter
than sizeof("struct sockaddr"-&gt;sa_family) bytes.

Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: initialize _pad of sockaddr_in before copying to user memory</title>
<updated>2019-04-02T01:08:19Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-03-31T08:58:15Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=09279e615c81ce55e04835970601ae286e3facbe'/>
<id>urn:sha1:09279e615c81ce55e04835970601ae286e3facbe</id>
<content type='text'>
Syzbot report a kernel-infoleak:

  BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
  Call Trace:
    _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
    copy_to_user include/linux/uaccess.h:174 [inline]
    sctp_getsockopt_peer_addrs net/sctp/socket.c:5911 [inline]
    sctp_getsockopt+0x1668e/0x17f70 net/sctp/socket.c:7562
    ...
  Uninit was stored to memory at:
    sctp_transport_init net/sctp/transport.c:61 [inline]
    sctp_transport_new+0x16d/0x9a0 net/sctp/transport.c:115
    sctp_assoc_add_peer+0x532/0x1f70 net/sctp/associola.c:637
    sctp_process_param net/sctp/sm_make_chunk.c:2548 [inline]
    sctp_process_init+0x1a1b/0x3ed0 net/sctp/sm_make_chunk.c:2361
    ...
  Bytes 8-15 of 16 are uninitialized

It was caused by that th _pad field (the 8-15 bytes) of a v4 addr (saved in
struct sockaddr_in) wasn't initialized, but directly copied to user memory
in sctp_getsockopt_peer_addrs().

So fix it by calling memset(addr-&gt;v4.sin_zero, 0, 8) to initialize _pad of
sockaddr_in before copying it to user memory in sctp_v4_addr_to_user(), as
sctp_v6_addr_to_user() does.

Reported-by: syzbot+86b5c7c236a22616a72f@syzkaller.appspotmail.com
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Tested-by: Alexander Potapenko &lt;glider@google.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: use memdup_user instead of vmemdup_user</title>
<updated>2019-03-20T18:09:47Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-03-20T06:49:38Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ef82bcfa671b9a635bab5fa669005663d8b177c5'/>
<id>urn:sha1:ef82bcfa671b9a635bab5fa669005663d8b177c5</id>
<content type='text'>
In sctp_setsockopt_bindx()/__sctp_setsockopt_connectx(), it allocates
memory with addrs_size which is passed from userspace. We used flag
GFP_USER to put some more restrictions on it in Commit cacc06215271
("sctp: use GFP_USER for user-controlled kmalloc").

However, since Commit c981f254cc82 ("sctp: use vmemdup_user() rather
than badly open-coding memdup_user()"), vmemdup_user() has been used,
which doesn't check GFP_USER flag when goes to vmalloc_*(). So when
addrs_size is a huge value, it could exhaust memory and even trigger
oom killer.

This patch is to use memdup_user() instead, in which GFP_USER would
work to limit the memory allocation with a huge addrs_size.

Note we can't fix it by limiting 'addrs_size', as there's no demand
for it from RFC.

Reported-by: syzbot+ec1b7575afef85a0e5ca@syzkaller.appspotmail.com
Fixes: c981f254cc82 ("sctp: use vmemdup_user() rather than badly open-coding memdup_user()")
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_STREAM_SCHEDULER sockopt</title>
<updated>2019-03-19T01:31:09Z</updated>
<author>
<name>Xin Long</name>
<email>lucien.xin@gmail.com</email>
</author>
<published>2019-03-18T12:06:11Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=b59c19d9d901a8eb04896ec027787a55acb71fc6'/>
<id>urn:sha1:b59c19d9d901a8eb04896ec027787a55acb71fc6</id>
<content type='text'>
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_STREAM_SCHEDULER sockopt.

Fixes: 7efba10d6bd2 ("sctp: add SCTP_FUTURE_ASOC and SCTP_CURRENT_ASSOC for SCTP_STREAM_SCHEDULER sockopt")
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
