<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/sctp/socket.c, branch linux-4.8.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.8.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.8.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-11-21T09:11:36Z</updated>
<entry>
<title>sctp: change sk state only when it has assocs in sctp_shutdown</title>
<updated>2016-11-21T09:11:36Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2016-11-13T13:44:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=150b491b1b88d467ee6e2982b7baa074e53b60a0'/>
<id>urn:sha1:150b491b1b88d467ee6e2982b7baa074e53b60a0</id>
<content type='text'>
[ Upstream commit 5bf35ddfee052d44f39ebaa395d87101c8918405 ]

Now when users shutdown a sock with SEND_SHUTDOWN in sctp, even if
this sock has no connection (assoc), sk state would be changed to
SCTP_SS_CLOSING, which is not as we expect.

Besides, after that if users try to listen on this sock, kernel
could even panic when it dereference sctp_sk(sk)-&gt;bind_hash in
sctp_inet_listen, as bind_hash is null when sock has no assoc.

This patch is to move sk state change after checking sk assocs
is not empty, and also merge these two if() conditions and reduce
indent level.

Fixes: d46e416c11c8 ("sctp: sctp should change socket state when shutdown is received")
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Acked-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.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: assign assoc_id earlier in __sctp_connect</title>
<updated>2016-11-21T09:11:35Z</updated>
<author>
<name>Marcelo Ricardo Leitner</name>
</author>
<published>2016-11-03T19:03:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=de289ad2e5754953716f8d835846c804137a3a08'/>
<id>urn:sha1:de289ad2e5754953716f8d835846c804137a3a08</id>
<content type='text'>
[ Upstream commit 7233bc84a3aeda835d334499dc00448373caf5c0 ]

sctp_wait_for_connect() currently already holds the asoc to keep it
alive during the sleep, in case another thread release it. But Andrey
Konovalov and Dmitry Vyukov reported an use-after-free in such
situation.

Problem is that __sctp_connect() doesn't get a ref on the asoc and will
do a read on the asoc after calling sctp_wait_for_connect(), but by then
another thread may have closed it and the _put on sctp_wait_for_connect
will actually release it, causing the use-after-free.

Fix is, instead of doing the read after waiting for the connect, do it
before so, and avoid this issue as the socket is still locked by then.
There should be no issue on returning the asoc id in case of failure as
the application shouldn't trust on that number in such situations
anyway.

This issue doesn't exist in sctp_sendmsg() path.

Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Tested-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Signed-off-by: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Reviewed-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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>net: sctp, forbid negative length</title>
<updated>2016-11-15T06:48:53Z</updated>
<author>
<name>Jiri Slaby</name>
</author>
<published>2016-10-21T12:13:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d90cbfaf5439361f56ef447d5e0d653233574f91'/>
<id>urn:sha1:d90cbfaf5439361f56ef447d5e0d653233574f91</id>
<content type='text'>
[ Upstream commit a4b8e71b05c27bae6bad3bdecddbc6b68a3ad8cf ]

Most of getsockopt handlers in net/sctp/socket.c check len against
sizeof some structure like:
        if (len &lt; sizeof(int))
                return -EINVAL;

On the first look, the check seems to be correct. But since len is int
and sizeof returns size_t, int gets promoted to unsigned size_t too. So
the test returns false for negative lengths. Yes, (-1 &lt; sizeof(long)) is
false.

Fix this in sctp by explicitly checking len &lt; 0 before any getsockopt
handler is called.

Note that sctp_getsockopt_events already handled the negative case.
Since we added the &lt; 0 check elsewhere, this one can be removed.

If not checked, this is the result:
UBSAN: Undefined behaviour in ../mm/page_alloc.c:2722:19
shift exponent 52 is too large for 32-bit type 'int'
CPU: 1 PID: 24535 Comm: syz-executor Not tainted 4.8.1-0-syzkaller #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.1-0-gb3ef39f-prebuilt.qemu-project.org 04/01/2014
 0000000000000000 ffff88006d99f2a8 ffffffffb2f7bdea 0000000041b58ab3
 ffffffffb4363c14 ffffffffb2f7bcde ffff88006d99f2d0 ffff88006d99f270
 0000000000000000 0000000000000000 0000000000000034 ffffffffb5096422
Call Trace:
 [&lt;ffffffffb3051498&gt;] ? __ubsan_handle_shift_out_of_bounds+0x29c/0x300
...
 [&lt;ffffffffb273f0e4&gt;] ? kmalloc_order+0x24/0x90
 [&lt;ffffffffb27416a4&gt;] ? kmalloc_order_trace+0x24/0x220
 [&lt;ffffffffb2819a30&gt;] ? __kmalloc+0x330/0x540
 [&lt;ffffffffc18c25f4&gt;] ? sctp_getsockopt_local_addrs+0x174/0xca0 [sctp]
 [&lt;ffffffffc18d2bcd&gt;] ? sctp_getsockopt+0x10d/0x1b0 [sctp]
 [&lt;ffffffffb37c1219&gt;] ? sock_common_getsockopt+0xb9/0x150
 [&lt;ffffffffb37be2f5&gt;] ? SyS_getsockopt+0x1a5/0x270

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Vlad Yasevich &lt;vyasevich@gmail.com&gt;
Cc: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: linux-sctp@vger.kernel.org
Cc: netdev@vger.kernel.org
Acked-by: Neil Horman &lt;nhorman@tuxdriver.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 the issue sctp_diag uses lock_sock in rcu_read_lock</title>
<updated>2016-09-30T06:08:57Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2016-09-28T18:55:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1cceda7849809a8857fd9f26efe8846506c710e1'/>
<id>urn:sha1:1cceda7849809a8857fd9f26efe8846506c710e1</id>
<content type='text'>
When sctp dumps all the ep-&gt;assocs, it needs to lock_sock first,
but now it locks sock in rcu_read_lock, and lock_sock may sleep,
which would break rcu_read_lock.

This patch is to get and hold one sock when traversing the list.
After that and get out of rcu_read_lock, lock and dump it. Then
it will traverse the list again to get the next one until all
sctp socks are dumped.

For sctp_diag_dump_one, it fixes this issue by holding asoc and
moving cb() out of rcu_read_lock in sctp_transport_lookup_process.

Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file")
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: allow receiving msg when TCP-style sk is in CLOSED state</title>
<updated>2016-07-31T05:06:22Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2016-07-30T06:14:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e08786942e0ea3a3cb268e6c62523d40f1c5eeb8'/>
<id>urn:sha1:e08786942e0ea3a3cb268e6c62523d40f1c5eeb8</id>
<content type='text'>
Commit 141ddefce7c8 ("sctp: change sk state to CLOSED instead of
CLOSING in sctp_sock_migrate") changed sk state to CLOSED if the
assoc is closed when sctp_accept clones a new sk.

If there is still data in sk receive queue, users will not be able
to read it any more, as sctp_recvmsg returns directly if sk state
is CLOSED.

This patch is to add CLOSED state check in sctp_recvmsg to allow
reading data from TCP-style sk with CLOSED state as what TCP does.

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;
</content>
</entry>
<entry>
<title>net/sctp: terminate rhashtable walk correctly</title>
<updated>2016-07-26T00:43:57Z</updated>
<author>
<name>Vegard Nossum</name>
</author>
<published>2016-07-23T07:42:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5fc382d87517707ad77ea4c9c12e2a3fde2c838a'/>
<id>urn:sha1:5fc382d87517707ad77ea4c9c12e2a3fde2c838a</id>
<content type='text'>
I was seeing a lot of these:

    BUG: sleeping function called from invalid context at mm/slab.h:388
    in_atomic(): 0, irqs_disabled(): 0, pid: 14971, name: trinity-c2
    Preemption disabled at:[&lt;ffffffff819bcd46&gt;] rhashtable_walk_start+0x46/0x150

     [&lt;ffffffff81149abb&gt;] preempt_count_add+0x1fb/0x280
     [&lt;ffffffff83295722&gt;] _raw_spin_lock+0x12/0x40
     [&lt;ffffffff811aac87&gt;] console_unlock+0x2f7/0x930
     [&lt;ffffffff811ab5bb&gt;] vprintk_emit+0x2fb/0x520
     [&lt;ffffffff811aba6a&gt;] vprintk_default+0x1a/0x20
     [&lt;ffffffff812c171a&gt;] printk+0x94/0xb0
     [&lt;ffffffff811d6ed0&gt;] print_stack_trace+0xe0/0x170
     [&lt;ffffffff8115835e&gt;] ___might_sleep+0x3be/0x460
     [&lt;ffffffff81158490&gt;] __might_sleep+0x90/0x1a0
     [&lt;ffffffff8139b823&gt;] kmem_cache_alloc+0x153/0x1e0
     [&lt;ffffffff819bca1e&gt;] rhashtable_walk_init+0xfe/0x2d0
     [&lt;ffffffff82ec64de&gt;] sctp_transport_walk_start+0x1e/0x60
     [&lt;ffffffff82edd8ad&gt;] sctp_transport_seq_start+0x4d/0x150
     [&lt;ffffffff8143a82b&gt;] seq_read+0x27b/0x1180
     [&lt;ffffffff814f97fc&gt;] proc_reg_read+0xbc/0x180
     [&lt;ffffffff813d471b&gt;] __vfs_read+0xdb/0x610
     [&lt;ffffffff813d4d3a&gt;] vfs_read+0xea/0x2d0
     [&lt;ffffffff813d615b&gt;] SyS_pread64+0x11b/0x150
     [&lt;ffffffff8100334c&gt;] do_syscall_64+0x19c/0x410
     [&lt;ffffffff832960a5&gt;] return_from_SYSCALL_64+0x0/0x6a
     [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff

Apparently we always need to call rhashtable_walk_stop(), even when
rhashtable_walk_start() fails:

 * rhashtable_walk_start - Start a hash table walk
 * @iter:       Hash table iterator
 *
 * Start a hash table walk.  Note that we take the RCU lock in all
 * cases including when we return an error.  So you must always call
 * rhashtable_walk_stop to clean up.

otherwise we never call rcu_read_unlock() and we get the splat above.

Fixes: 53fa1036 ("sctp: fix some rhashtable functions using in sctp proc/diag")
See-also: 53fa1036 ("sctp: fix some rhashtable functions using in sctp proc/diag")
See-also: f2dba9c6 ("rhashtable: Introduce rhashtable_walk_*")
Cc: Xin Long &lt;lucien.xin@gmail.com&gt;
Cc: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.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: recvmsg should be able to run even if sock is in closing state</title>
<updated>2016-07-17T05:02:09Z</updated>
<author>
<name>Marcelo Ricardo Leitner</name>
</author>
<published>2016-07-15T19:38:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e5b13f3444dfe4f014343e83aa7948b83ef58168'/>
<id>urn:sha1:e5b13f3444dfe4f014343e83aa7948b83ef58168</id>
<content type='text'>
Commit d46e416c11c8 missed to update some other places which checked for
the socket being TCP-style AND Established state, as Closing state has
some overlapping with the previous understanding of Established.

Without this fix, one of the effects is that some already queued rx
messages may not be readable anymore depending on how the association
teared down, and sending may also not be possible if peer initiated the
shutdown.

Also merge two if() blocks into one condition on sctp_sendmsg().

Cc: Xin Long &lt;lucien.xin@gmail.com&gt;
Fixes: d46e416c11c8 ("sctp: sctp should change socket state when shutdown is received")
Signed-off-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: allow GSO frags to access the chunk too</title>
<updated>2016-07-14T01:10:14Z</updated>
<author>
<name>Marcelo Ricardo Leitner</name>
</author>
<published>2016-07-13T18:08:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1f45f78f8e511203f03138f2ccde3d2cf90d2cbf'/>
<id>urn:sha1:1f45f78f8e511203f03138f2ccde3d2cf90d2cbf</id>
<content type='text'>
SCTP will try to access original IP headers on sctp_recvmsg in order to
copy the addresses used. There are also other places that do similar access
to IP or even SCTP headers. But after 90017accff61 ("sctp: Add GSO
support") they aren't always there because they are only present in the
header skb.

SCTP handles the queueing of incoming data by cloning the incoming skb
and limiting to only the relevant payload. This clone has its cb updated
to something different and it's then queued on socket rx queue. Thus we
need to fix this in two moments.

For rx path, not related to socket queue yet, this patch uses a
partially copied sctp_input_cb to such GSO frags. This restores the
ability to access the headers for this part of the code.

Regarding the socket rx queue, it removes iif member from sctp_event and
also add a chunk pointer on it.

With these changes we're always able to reach the headers again.

The biggest change here is that now the sctp_chunk struct and the
original skb are only freed after the application consumed the buffer.
Note however that the original payload was already like this due to the
skb cloning.

For iif, SCTP's IPv4 code doesn't use it, so no change is necessary.
IPv6 now can fetch it directly from original's IPv6 CB as the original
skb is still accessible.

In the future we probably can simplify sctp_v*_skb_iif() stuff, as
sctp_v4_skb_iif() was called but it's return value not used, and now
it's not even called, but such cleanup is out of scope for this change.

Fixes: 90017accff61 ("sctp: Add GSO support")
Signed-off-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: implement prsctp PRIO policy</title>
<updated>2016-07-11T20:25:39Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2016-07-09T11:47:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8dbdf1f5b09cb22560e7c7173b52fe3c631046bd'/>
<id>urn:sha1:8dbdf1f5b09cb22560e7c7173b52fe3c631046bd</id>
<content type='text'>
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.

Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo-&gt;sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg-&gt;expire_at won't work.

asoc-&gt;sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.

In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size &gt;
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.

Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: implement prsctp TTL policy</title>
<updated>2016-07-11T20:25:39Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2016-07-09T11:47:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a6c2f792873aff332a4689717c3cd6104f46684c'/>
<id>urn:sha1:a6c2f792873aff332a4689717c3cd6104f46684c</id>
<content type='text'>
prsctp TTL policy is a policy to abandon chunks when they expire
at the specific time in local stack. It's similar with expires_at
in struct sctp_datamsg.

This patch uses sinfo-&gt;sinfo_timetolive to set the specific time for
TTL policy. sinfo-&gt;sinfo_timetolive is also used for msg-&gt;expires_at.
So if prsctp_enable or TTL policy is not enabled, msg-&gt;expires_at
still works as before.

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>
