<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/sctp/socket.c, branch linux-5.13.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-07-28T12:37:29Z</updated>
<entry>
<title>sctp: trim optlen when it's a huge value in sctp_setsockopt</title>
<updated>2021-07-28T12:37:29Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2021-07-17T21:19:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c9437655302c503caa2a7ecf7a3167ee6a02cbef'/>
<id>urn:sha1:c9437655302c503caa2a7ecf7a3167ee6a02cbef</id>
<content type='text'>
[ Upstream commit 2f3fdd8d4805015fa964807e1c7f3d88f31bd389 ]

After commit ca84bd058dae ("sctp: copy the optval from user space in
sctp_setsockopt"), it does memory allocation in sctp_setsockopt with
the optlen, and it would fail the allocation and return error if the
optlen from user space is a huge value.

This breaks some sockopts, like SCTP_HMAC_IDENT, SCTP_RESET_STREAMS and
SCTP_AUTH_KEY, as when processing these sockopts before, optlen would
be trimmed to a biggest value it needs when optlen is a huge value,
instead of failing the allocation and returning error.

This patch is to fix the allocation failure when it's a huge optlen from
user space by trimming it to the biggest size sctp sockopt may need when
necessary, and this biggest size is from sctp_setsockopt_reset_streams()
for SCTP_RESET_STREAMS, which is bigger than those for SCTP_HMAC_IDENT
and SCTP_AUTH_KEY.

Fixes: ca84bd058dae ("sctp: copy the optval from user space in sctp_setsockopt")
Signed-off-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>sctp: add the missing setting for asoc encap_port</title>
<updated>2021-05-25T22:17:26Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2021-05-25T02:49:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=297739bd73f6e49d80bac4bfd27f3598b798c0d4'/>
<id>urn:sha1:297739bd73f6e49d80bac4bfd27f3598b798c0d4</id>
<content type='text'>
This patch is to add the missing setting back for asoc encap_port.

Fixes: 8dba29603b5c ("sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT 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>
<entry>
<title>sctp: delay auto_asconf init until binding the first addr</title>
<updated>2021-05-03T20:36:21Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2021-05-02T21:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=34e5b01186858b36c4d7c87e1a025071e8e2401f'/>
<id>urn:sha1:34e5b01186858b36c4d7c87e1a025071e8e2401f</id>
<content type='text'>
As Or Cohen described:

  If sctp_destroy_sock is called without sock_net(sk)-&gt;sctp.addr_wq_lock
  held and sp-&gt;do_auto_asconf is true, then an element is removed
  from the auto_asconf_splist without any proper locking.

  This can happen in the following functions:
  1. In sctp_accept, if sctp_sock_migrate fails.
  2. In inet_create or inet6_create, if there is a bpf program
     attached to BPF_CGROUP_INET_SOCK_CREATE which denies
     creation of the sctp socket.

This patch is to fix it by moving the auto_asconf init out of
sctp_init_sock(), by which inet_create()/inet6_create() won't
need to operate it in sctp_destroy_sock() when calling
sk_common_release().

It also makes more sense to do auto_asconf init while binding the
first addr, as auto_asconf actually requires an ANY addr bind,
see it in sctp_addr_wq_timeout_handler().

This addresses CVE-2021-23133.

Fixes: 610236587600 ("bpf: Add new cgroup attach type to enable sock modifications")
Reported-by: Or Cohen &lt;orcohen@paloaltonetworks.com&gt;
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>Revert "net/sctp: fix race condition in sctp_destroy_sock"</title>
<updated>2021-05-03T20:36:21Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2021-05-02T21:11:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=01bfe5e8e428b475982a98a46cca5755726f3f7f'/>
<id>urn:sha1:01bfe5e8e428b475982a98a46cca5755726f3f7f</id>
<content type='text'>
This reverts commit b166a20b07382b8bc1dcee2a448715c9c2c81b5b.

This one has to be reverted as it introduced a dead lock, as
syzbot reported:

       CPU0                    CPU1
       ----                    ----
  lock(&amp;net-&gt;sctp.addr_wq_lock);
                               lock(slock-AF_INET6);
                               lock(&amp;net-&gt;sctp.addr_wq_lock);
  lock(slock-AF_INET6);

CPU0 is the thread of sctp_addr_wq_timeout_handler(), and CPU1
is that of sctp_close().

The original issue this commit fixed will be fixed in the next
patch.

Reported-by: syzbot+959223586843e69a2674@syzkaller.appspotmail.com
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>Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net</title>
<updated>2021-04-17T18:08:07Z</updated>
<author>
<name>Jakub Kicinski</name>
</author>
<published>2021-04-17T17:42:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8203c7ce4ef2840929d38b447b4ccd384727f92b'/>
<id>urn:sha1:8203c7ce4ef2840929d38b447b4ccd384727f92b</id>
<content type='text'>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
 - keep the ZC code, drop the code related to reinit
net/bridge/netfilter/ebtables.c
 - fix build after move to net_generic

Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net/sctp: fix race condition in sctp_destroy_sock</title>
<updated>2021-04-13T21:59:46Z</updated>
<author>
<name>Or Cohen</name>
</author>
<published>2021-04-13T18:10:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b166a20b07382b8bc1dcee2a448715c9c2c81b5b'/>
<id>urn:sha1:b166a20b07382b8bc1dcee2a448715c9c2c81b5b</id>
<content type='text'>
If sctp_destroy_sock is called without sock_net(sk)-&gt;sctp.addr_wq_lock
held and sp-&gt;do_auto_asconf is true, then an element is removed
from the auto_asconf_splist without any proper locking.

This can happen in the following functions:
1. In sctp_accept, if sctp_sock_migrate fails.
2. In inet_create or inet6_create, if there is a bpf program
   attached to BPF_CGROUP_INET_SOCK_CREATE which denies
   creation of the sctp socket.

The bug is fixed by acquiring addr_wq_lock in sctp_destroy_sock
instead of sctp_close.

This addresses CVE-2021-23133.

Reported-by: Or Cohen &lt;orcohen@paloaltonetworks.com&gt;
Reviewed-by: Xin Long &lt;lucien.xin@gmail.com&gt;
Fixes: 610236587600 ("bpf: Add new cgroup attach type to enable sock modifications")
Signed-off-by: Or Cohen &lt;orcohen@paloaltonetworks.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: Fix some typos</title>
<updated>2021-03-29T00:52:50Z</updated>
<author>
<name>Lu Wei</name>
</author>
<published>2021-03-27T02:27:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=21c00a186fac6e035eef5e6751f1e2d2609f969c'/>
<id>urn:sha1:21c00a186fac6e035eef5e6751f1e2d2609f969c</id>
<content type='text'>
Modify "unkown" to "unknown" in net/sctp/sm_make_chunk.c and
Modify "orginal" to "original" in net/sctp/socket.c.

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Lu Wei &lt;luwei32@huawei.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sctp: add udphdr to overhead when udp_port is set</title>
<updated>2020-10-30T22:24:21Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2020-10-29T07:05:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f1bfe8b5415171b5e70c2a47d399c91bd7c2752e'/>
<id>urn:sha1:f1bfe8b5415171b5e70c2a47d399c91bd7c2752e</id>
<content type='text'>
sctp_mtu_payload() is for calculating the frag size before making
chunks from a msg. So we should only add udphdr size to overhead
when udp socks are listening, as only then sctp can handle the
incoming sctp over udp packets and outgoing sctp over udp packets
will be possible.

Note that we can't do this according to transport-&gt;encap_port, as
different transports may be set to different values, while the
chunks were made before choosing the transport, we could not be
able to meet all rfc6951#section-5.6 recommends.

v1-&gt;v2:
  - Add udp_port for sctp_sock to avoid a potential race issue, it
    will be used in xmit path in the next patch.

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: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt</title>
<updated>2020-10-30T22:24:11Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2020-10-29T07:05:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8dba29603b5c8bfca2bf90aeb83d05a236df967b'/>
<id>urn:sha1:8dba29603b5c8bfca2bf90aeb83d05a236df967b</id>
<content type='text'>
This patch is to implement:

  rfc6951#section-6.1: Get or Set the Remote UDP Encapsulation Port Number

with the param of the struct:

  struct sctp_udpencaps {
    sctp_assoc_t sue_assoc_id;
    struct sockaddr_storage sue_address;
    uint16_t sue_port;
  };

the encap_port of sock, assoc or transport can be changed by users,
which also means it allows the different transports of the same asoc
to have different encap_port value.

v1-&gt;v2:
  - no change.
v2-&gt;v3:
  - fix the endian warning when setting values between encap_port and
    sue_port.

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: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>sctp: add encap_port for netns sock asoc and transport</title>
<updated>2020-10-30T22:24:06Z</updated>
<author>
<name>Xin Long</name>
</author>
<published>2020-10-29T07:05:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e8a3001c2120c760017da81a307308572a3cdbbc'/>
<id>urn:sha1:e8a3001c2120c760017da81a307308572a3cdbbc</id>
<content type='text'>
encap_port is added as per netns/sock/assoc/transport, and the
latter one's encap_port inherits the former one's by default.
The transport's encap_port value would mostly decide if one
packet should go out with udp encapsulated or not.

This patch also allows users to set netns' encap_port by sysctl.

v1-&gt;v2:
  - Change to define encap_port as __be16 for sctp_sock, asoc and
    transport.
v2-&gt;v3:
  - No change.
v3-&gt;v4:
  - Add 'encap_port' entry in ip-sysctl.rst.
v4-&gt;v5:
  - Improve the description of encap_port in ip-sysctl.rst.

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: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
</feed>
