07 Feb, 2019

2 commits

  • [ Upstream commit 2e6dc4d95110becfe0ff4c3d4749c33ea166e9e7 ]

    This patch is to improve sctp stream reset events in 4 places:

    1. In sctp_process_strreset_outreq(), the flag should always be set with
    SCTP_STREAM_RESET_INCOMING_SSN instead of OUTGOING, as receiver's in
    stream is reset here.
    2. In sctp_process_strreset_outreq(), move up SCTP_STRRESET_ERR_WRONG_SSN
    check, as the reset has to succeed after reconf_timer stops for the
    in stream reset request retransmission.
    3. In sctp_process_strreset_inreq(), no event should be sent, as no in
    or out stream is reset here.
    4. In sctp_process_strreset_resp(), SCTP_STREAM_RESET_INCOMING_SSN or
    OUTGOING event should always be sent for stream reset requests, no
    matter it fails or succeeds to process the request.

    Fixes: 810544764536 ("sctp: implement receiver-side procedures for the Outgoing SSN Reset Request Parameter")
    Fixes: 16e1a91965b0 ("sctp: implement receiver-side procedures for the Incoming SSN Reset Request Parameter")
    Fixes: 11ae76e67a17 ("sctp: implement receiver-side procedures for the Reconf Response Parameter")
    Reported-by: Ying Xu
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 8220c870cb0f4eaa4e335c9645dbd9a1c461c1dd ]

    This patch is to improve sctp stream adding events in 2 places:

    1. In sctp_process_strreset_addstrm_out(), move up SCTP_MAX_STREAM
    and in stream allocation failure checks, as the adding has to
    succeed after reconf_timer stops for the in stream adding
    request retransmission.

    3. In sctp_process_strreset_addstrm_in(), no event should be sent,
    as no in or out stream is added here.

    Fixes: 50a41591f110 ("sctp: implement receiver-side procedures for the Add Outgoing Streams Request Parameter")
    Fixes: c5c4ebb3ab87 ("sctp: implement receiver-side procedures for the Add Incoming Streams Request Parameter")
    Reported-by: Ying Xu
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

23 Jan, 2019

1 commit

  • commit 400b8b9a2a17918f8ce00786f596f530e7f30d50 upstream.

    The similar issue as fixed in Commit 4a2eb0c37b47 ("sctp: initialize
    sin6_flowinfo for ipv6 addrs in sctp_inet6addr_event") also exists
    in sctp_inetaddr_event, as Alexander noticed.

    To fix it, allocate sctp_sockaddr_entry with kzalloc for both sctp
    ipv4 and ipv6 addresses, as does in sctp_v4/6_copy_addrlist().

    Reported-by: Alexander Potapenko
    Signed-off-by: Xin Long
    Reported-by: syzbot+ae0c70c0c2d40c51bb92@syzkaller.appspotmail.com
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

10 Jan, 2019

1 commit

  • [ Upstream commit 4a2eb0c37b4759416996fbb4c45b932500cf06d3 ]

    syzbot reported a kernel-infoleak, which is caused by an uninitialized
    field(sin6_flowinfo) of addr->a.v6 in sctp_inet6addr_event().
    The call trace is as below:

    BUG: KMSAN: kernel-infoleak in _copy_to_user+0x19a/0x230 lib/usercopy.c:33
    CPU: 1 PID: 8164 Comm: syz-executor2 Not tainted 4.20.0-rc3+ #95
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x32d/0x480 lib/dump_stack.c:113
    kmsan_report+0x12c/0x290 mm/kmsan/kmsan.c:683
    kmsan_internal_check_memory+0x32a/0xa50 mm/kmsan/kmsan.c:743
    kmsan_copy_to_user+0x78/0xd0 mm/kmsan/kmsan_hooks.c:634
    _copy_to_user+0x19a/0x230 lib/usercopy.c:33
    copy_to_user include/linux/uaccess.h:183 [inline]
    sctp_getsockopt_local_addrs net/sctp/socket.c:5998 [inline]
    sctp_getsockopt+0x15248/0x186f0 net/sctp/socket.c:7477
    sock_common_getsockopt+0x13f/0x180 net/core/sock.c:2937
    __sys_getsockopt+0x489/0x550 net/socket.c:1939
    __do_sys_getsockopt net/socket.c:1950 [inline]
    __se_sys_getsockopt+0xe1/0x100 net/socket.c:1947
    __x64_sys_getsockopt+0x62/0x80 net/socket.c:1947
    do_syscall_64+0xcf/0x110 arch/x86/entry/common.c:291
    entry_SYSCALL_64_after_hwframe+0x63/0xe7

    sin6_flowinfo is not really used by SCTP, so it will be fixed by simply
    setting it to 0.

    The issue exists since very beginning.
    Thanks Alexander for the reproducer provided.

    Reported-by: syzbot+ad5d327e6936a2e284be@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

17 Dec, 2018

1 commit

  • [ Upstream commit fb6df5a6234c38a9c551559506a49a677ac6f07a ]

    In sctp_hash_transport/sctp_epaddr_lookup_transport, it dereferences
    a transport's asoc under rcu_read_lock while asoc is freed not after
    a grace period, which leads to a use-after-free panic.

    This patch fixes it by calling kfree_rcu to make asoc be freed after
    a grace period.

    Note that only the asoc's memory is delayed to free in the patch, it
    won't cause sk to linger longer.

    Thanks Neil and Marcelo to make this clear.

    Fixes: 7fda702f9315 ("sctp: use new rhlist interface on sctp transport rhashtable")
    Fixes: cd2b70875058 ("sctp: check duplicate node before inserting a new transport")
    Reported-by: syzbot+0b05d8aa7cb185107483@syzkaller.appspotmail.com
    Reported-by: syzbot+aad231d51b1923158444@syzkaller.appspotmail.com
    Suggested-by: Neil Horman
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

01 Dec, 2018

1 commit

  • commit df132eff463873e14e019a07f387b4d577d6d1f9 upstream.

    If a transport is removed by asconf but there still are some chunks with
    this transport queuing on out_chunk_list, later an use-after-free issue
    will be caused when accessing this transport from these chunks in
    sctp_outq_flush().

    This is an old bug, we fix it by clearing the transport of these chunks
    in out_chunk_list when removing a transport in sctp_assoc_rm_peer().

    Reported-by: syzbot+56a40ceee5fb35932f4d@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

23 Nov, 2018

2 commits

  • [ Upstream commit e1e46479847e66f78f79d8c24d5169a5954b3fc2 ]

    Different from processing the addstrm_out request, The receiver handles
    an addstrm_in request by sending back an addstrm_out request to the
    sender who will increase its stream's in and incnt later.

    Now stream->incnt has been increased since it sent out the addstrm_in
    request in sctp_send_add_streams(), with the wrong stream->incnt will
    even cause crash when copying stream info from the old stream's in to
    the new one's in sctp_process_strreset_addstrm_out().

    This patch is to fix it by simply removing the stream->incnt change
    from sctp_send_add_streams().

    Fixes: 242bd2d519d7 ("sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Request Parameter")
    Reported-by: Jianwen Ji
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit cc3ccf26f0649089b3a34a2781977755ea36e72c ]

    As rfc7496#section4.5 says about SCTP_PR_SUPPORTED:

    This socket option allows the enabling or disabling of the
    negotiation of PR-SCTP support for future associations. For existing
    associations, it allows one to query whether or not PR-SCTP support
    was negotiated on a particular association.

    It means only sctp sock's prsctp_enable can be set.

    Note that for the limitation of SCTP_{CURRENT|ALL}_ASSOC, we will
    add it when introducing SCTP_{FUTURE|CURRENT|ALL}_ASSOC for linux
    sctp in another patchset.

    v1->v2:
    - drop the params.assoc_id check as Neil suggested.

    Fixes: 28aa4c26fce2 ("sctp: add SCTP_PR_SUPPORTED on sctp sockopt")
    Reported-by: Ying Xu
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

04 Nov, 2018

1 commit

  • [ Upstream commit b336decab22158937975293aea79396525f92bb3 ]

    syzbot reported an use-after-free involving sctp_id2asoc. Dmitry Vyukov
    helped to root cause it and it is because of reading the asoc after it
    was freed:

    CPU 1 CPU 2
    (working on socket 1) (working on socket 2)
    sctp_association_destroy
    sctp_id2asoc
    spin lock
    grab the asoc from idr
    spin unlock
    spin lock
    remove asoc from idr
    spin unlock
    free(asoc)
    if asoc->base.sk != sk ... [*]

    This can only be hit if trying to fetch asocs from different sockets. As
    we have a single IDR for all asocs, in all SCTP sockets, their id is
    unique on the system. An application can try to send stuff on an id
    that matches on another socket, and the if in [*] will protect from such
    usage. But it didn't consider that as that asoc may belong to another
    socket, it may be freed in parallel (read: under another socket lock).

    We fix it by moving the checks in [*] into the protected region. This
    fixes it because the asoc cannot be freed while the lock is held.

    Reported-by: syzbot+c7dd55d7aec49d48e49a@syzkaller.appspotmail.com
    Acked-by: Dmitry Vyukov
    Signed-off-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     

18 Oct, 2018

1 commit

  • [ Upstream commit d7ab5cdce54da631f0c8c11e506c974536a3581e ]

    When processing pmtu update from an icmp packet, it calls .update_pmtu
    with sk instead of skb in sctp_transport_update_pmtu.

    However for sctp, the daddr in the transport might be different from
    inet_sock->inet_daddr or sk->sk_v6_daddr, which is used to update or
    create the route cache. The incorrect daddr will cause a different
    route cache created for the path.

    So before calling .update_pmtu, inet_sock->inet_daddr/sk->sk_v6_daddr
    should be updated with the daddr in the transport, and update it back
    after it's done.

    The issue has existed since route exceptions introduction.

    Fixes: 4895c771c7f0 ("ipv4: Add FIB nexthop exceptions.")
    Reported-by: ian.periam@dialogic.com
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

15 Sep, 2018

1 commit

  • [ Upstream commit bab1be79a5169ac748d8292b20c86d874022d7ba ]

    As Marcelo noticed, in sctp_transport_get_next, it is iterating over
    transports but then also accessing the association directly, without
    checking any refcnts before that, which can cause an use-after-free
    Read.

    So fix it by holding transport before accessing the association. With
    that, sctp_transport_hold calls can be removed in the later places.

    Fixes: 626d16f50f39 ("sctp: export some apis or variables for sctp_diag and reuse some for proc")
    Reported-by: syzbot+fe62a0c9aa6a85c6de16@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

24 Aug, 2018

1 commit

  • [ Upstream commit fedb1bd3d274b33c432cb83c80c6b3cf54d509c8 ]

    Currently it is incrementing SctpFragUsrMsgs when the user message size
    is of the exactly same size as the maximum fragment size, which is wrong.

    The fix is to increment it only when user message is bigger than the
    maximum fragment size.

    Fixes: bfd2e4b8734d ("sctp: refactor sctp_datamsg_from_user")
    Signed-off-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     

12 Jun, 2018

1 commit

  • [ Upstream commit 1d88ba1ebb2763aa86172cd7ca05dedbeccc0d35 ]

    syzbot reported a rcu_sched self-detected stall on CPU which is caused
    by too small value set on rto_min with SCTP_RTOINFO sockopt. With this
    value, hb_timer will get stuck there, as in its timer handler it starts
    this timer again with this value, then goes to the timer handler again.

    This problem is there since very beginning, and thanks to Eric for the
    reproducer shared from a syzbot mail.

    This patch fixes it by not allowing sctp_transport_timeout to return a
    smaller value than HZ/5 for hb_timer, which is based on TCP's min rto.

    Note that it doesn't fix this issue by limiting rto_min, as some users
    are still using small rto and no proper value was found for it yet.

    Reported-by: syzbot+3dcd59a1f907245f891f@syzkaller.appspotmail.com
    Suggested-by: Marcelo Ricardo Leitner
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

19 May, 2018

5 commits

  • [ Upstream commit 46e16d4b956867013e0bbd7f2bad206f4aa55752 ]

    When processing a duplicate cookie-echo chunk, for case 'D', sctp will
    not process the param from this chunk. It means old asoc has nothing
    to be updated, and the new temp asoc doesn't have the complete info.

    So there's no reason to use the new asoc when creating the cookie-ack
    chunk. Otherwise, like when auth is enabled for cookie-ack, the chunk
    can not be set with auth, and it will definitely be dropped by peer.

    This issue is there since very beginning, and we fix it by using the
    old asoc instead.

    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 6910e25de2257e2c82c7a2d126e3463cd8e50810 ]

    In Commit 1f45f78f8e51 ("sctp: allow GSO frags to access the chunk too"),
    it held the chunk in sctp_ulpevent_make_rcvmsg to access it safely later
    in recvmsg. However, it also added sctp_chunk_put in fail_mark err path,
    which is only triggered before holding the chunk.

    syzbot reported a use-after-free crash happened on this err path, where
    it shouldn't call sctp_chunk_put.

    This patch simply removes this call.

    Fixes: 1f45f78f8e51 ("sctp: allow GSO frags to access the chunk too")
    Reported-by: syzbot+141d898c5f24489db4aa@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit d625329b06e46bd20baf9ee40847d11982569204 ]

    Since sctp ipv6 socket also supports v4 addrs, it's possible to
    compare two v4 addrs in pf v6 .cmp_addr, sctp_inet6_cmp_addr.

    However after Commit 1071ec9d453a ("sctp: do not check port in
    sctp_inet6_cmp_addr"), it no longer calls af1->cmp_addr, which
    in this case is sctp_v4_cmp_addr, but calls __sctp_v6_cmp_addr
    where it handles them as two v6 addrs. It would cause a out of
    bounds crash.

    syzbot found this crash when trying to bind two v4 addrs to a
    v6 socket.

    This patch fixes it by adding the process for two v4 addrs in
    sctp_inet6_cmp_addr.

    Fixes: 1071ec9d453a ("sctp: do not check port in sctp_inet6_cmp_addr")
    Reported-by: syzbot+cd494c1dd681d4d93ebb@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit ce402f044e4e432c296f90eaabb8dbe8f3624391 ]

    When auth is enabled for cookie-ack chunk, in sctp_inq_pop, sctp
    processes auth chunk first, then continues to the next chunk in
    this packet if chunk_end + chunk_hdr size < skb_tail_pointer().
    Otherwise, it will go to the next packet or discard this chunk.

    However, it missed the fact that cookie-ack chunk's size is equal
    to chunk_hdr size, which couldn't match that check, and thus this
    chunk would not get processed.

    This patch fixes it by changing the check to chunk_end + chunk_hdr
    size
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 59d8d4434f429b4fa8a346fd889058bda427a837 ]

    Now sctp only delays the authentication for the normal cookie-echo
    chunk by setting chunk->auth_chunk in sctp_endpoint_bh_rcv(). But
    for the duplicated one with auth, in sctp_assoc_bh_rcv(), it does
    authentication first based on the old asoc, which will definitely
    fail due to the different auth info in the old asoc.

    The duplicated cookie-echo chunk will create a new asoc with the
    auth info from this chunk, and the authentication should also be
    done with the new asoc's auth info for all of the collision 'A',
    'B' and 'D'. Otherwise, the duplicated cookie-echo chunk with auth
    will never pass the authentication and create the new connection.

    This issue exists since very beginning, and this fix is to make
    sctp_assoc_bh_rcv() follow the way sctp_endpoint_bh_rcv() does
    for the normal cookie-echo chunk to delay the authentication.

    While at it, remove the unused params from sctp_sf_authenticate()
    and define sctp_auth_chunk_verify() used for all the places that
    do the delayed authentication.

    v1->v2:
    fix the typo in changelog as Marcelo noticed.

    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

29 Apr, 2018

1 commit

  • [ Upstream commit 1071ec9d453a38023579714b64a951a2fb982071 ]

    pf->cmp_addr() is called before binding a v6 address to the sock. It
    should not check ports, like in sctp_inet_cmp_addr.

    But sctp_inet6_cmp_addr checks the addr by invoking af(6)->cmp_addr,
    sctp_v6_cmp_addr where it also compares the ports.

    This would cause that setsockopt(SCTP_SOCKOPT_BINDX_ADD) could bind
    multiple duplicated IPv6 addresses after Commit 40b4f0fd74e4 ("sctp:
    lack the check for ports in sctp_v6_cmp_addr").

    This patch is to remove af->cmp_addr called in sctp_inet6_cmp_addr,
    but do the proper check for both v6 addrs and v4mapped addrs.

    v1->v2:
    - define __sctp_v6_cmp_addr to do the common address comparison
    used for both pf and af v6 cmp_addr.

    Fixes: 40b4f0fd74e4 ("sctp: lack the check for ports in sctp_v6_cmp_addr")
    Reported-by: Jianwen Ji
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

12 Apr, 2018

2 commits

  • [ Upstream commit 81e98370293afcb58340ce8bd71af7b97f925c26 ]

    Check must happen before call to ipv6_addr_v4mapped()

    syzbot report was :

    BUG: KMSAN: uninit-value in sctp_sockaddr_af net/sctp/socket.c:359 [inline]
    BUG: KMSAN: uninit-value in sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384
    CPU: 0 PID: 3576 Comm: syzkaller968804 Not tainted 4.16.0+ #82
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:17 [inline]
    dump_stack+0x185/0x1d0 lib/dump_stack.c:53
    kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
    __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676
    sctp_sockaddr_af net/sctp/socket.c:359 [inline]
    sctp_do_bind+0x60f/0xdc0 net/sctp/socket.c:384
    sctp_bind+0x149/0x190 net/sctp/socket.c:332
    inet6_bind+0x1fd/0x1820 net/ipv6/af_inet6.c:293
    SYSC_bind+0x3f2/0x4b0 net/socket.c:1474
    SyS_bind+0x54/0x80 net/socket.c:1460
    do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x43fd49
    RSP: 002b:00007ffe99df3d28 EFLAGS: 00000213 ORIG_RAX: 0000000000000031
    RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fd49
    RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000003
    RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8
    R10: 00000000004002c8 R11: 0000000000000213 R12: 0000000000401670
    R13: 0000000000401700 R14: 0000000000000000 R15: 0000000000000000

    Local variable description: ----address@SYSC_bind
    Variable was created at:
    SYSC_bind+0x6f/0x4b0 net/socket.c:1461
    SyS_bind+0x54/0x80 net/socket.c:1460

    Signed-off-by: Eric Dumazet
    Cc: Vlad Yasevich
    Cc: Neil Horman
    Reported-by: syzbot
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit 6780db244d6b1537d139dea0ec8aad10cf9e4adb ]

    syzbot produced a nice report [1]

    Issue here is that a recvmmsg() managed to leak 8 bytes of kernel memory
    to user space, because sin_zero (padding field) was not properly cleared.

    [1]
    BUG: KMSAN: uninit-value in copy_to_user include/linux/uaccess.h:184 [inline]
    BUG: KMSAN: uninit-value in move_addr_to_user+0x32e/0x530 net/socket.c:227
    CPU: 1 PID: 3586 Comm: syzkaller481044 Not tainted 4.16.0+ #82
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:17 [inline]
    dump_stack+0x185/0x1d0 lib/dump_stack.c:53
    kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
    kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176
    kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199
    copy_to_user include/linux/uaccess.h:184 [inline]
    move_addr_to_user+0x32e/0x530 net/socket.c:227
    ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211
    __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313
    SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394
    SyS_recvmmsg+0x76/0xa0 net/socket.c:2378
    do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x4401c9
    RSP: 002b:00007ffc56f73098 EFLAGS: 00000217 ORIG_RAX: 000000000000012b
    RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004401c9
    RDX: 0000000000000001 RSI: 0000000020003ac0 RDI: 0000000000000003
    RBP: 00000000006ca018 R08: 0000000020003bc0 R09: 0000000000000010
    R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000401af0
    R13: 0000000000401b80 R14: 0000000000000000 R15: 0000000000000000

    Local variable description: ----addr@___sys_recvmsg
    Variable was created at:
    ___sys_recvmsg+0xd5/0x810 net/socket.c:2172
    __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313

    Bytes 8-15 of 16 are uninitialized

    ==================================================================
    Kernel panic - not syncing: panic_on_warn set ...

    CPU: 1 PID: 3586 Comm: syzkaller481044 Tainted: G B 4.16.0+ #82
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:17 [inline]
    dump_stack+0x185/0x1d0 lib/dump_stack.c:53
    panic+0x39d/0x940 kernel/panic.c:183
    kmsan_report+0x238/0x240 mm/kmsan/kmsan.c:1083
    kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176
    kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199
    copy_to_user include/linux/uaccess.h:184 [inline]
    move_addr_to_user+0x32e/0x530 net/socket.c:227
    ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211
    __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313
    SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394
    SyS_recvmmsg+0x76/0xa0 net/socket.c:2378
    do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet
    Cc: Vlad Yasevich
    Cc: Neil Horman
    Reported-by: syzbot
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     

09 Mar, 2018

4 commits

  • [ Upstream commit 957d761cf91cdbb175ad7d8f5472336a4d54dbf2 ]

    When going through the bind address list in sctp_v6_get_dst() and
    the previously found address is better ('matchlen > bmatchlen'),
    the code continues to the next iteration without releasing currently
    held destination.

    Fix it by releasing 'bdst' before continue to the next iteration, and
    instead of introducing one more '!IS_ERR(bdst)' check for dst_release(),
    move the already existed one right after ip6_dst_lookup_flow(), i.e. we
    shouldn't proceed further if we get an error for the route lookup.

    Fixes: dbc2b5e9a09e ("sctp: fix src address selection if using secondary addresses for ipv6")
    Signed-off-by: Alexey Kodanev
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Alexey Kodanev
     
  • [ Upstream commit 27af86bb038d9c8b8066cd17854ddaf2ea92bce1 ]

    The pr_err in sctp_hash_transport was supposed to report a sctp bug
    for using rhashtable/rhlist.

    The err '-EEXIST' introduced in Commit cd2b70875058 ("sctp: check
    duplicate node before inserting a new transport") doesn't belong
    to that case.

    So just return -EEXIST back without pr_err any kmsg.

    Fixes: cd2b70875058 ("sctp: check duplicate node before inserting a new transport")
    Reported-by: Wei Chen
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 4a31a6b19f9ddf498c81f5c9b089742b7472a6f8 ]

    Fix dst reference count leak in sctp_v4_get_dst() introduced in commit
    410f03831 ("sctp: add routing output fallback"):

    When walking the address_list, successive ip_route_output_key() calls
    may return the same rt->dst with the reference incremented on each call.

    The code would not decrement the dst refcount when the dst pointer was
    identical from the previous iteration, causing the dst refcnt leak.

    Testcase:
    ip netns add TEST
    ip netns exec TEST ip link set lo up
    ip link add dummy0 type dummy
    ip link add dummy1 type dummy
    ip link add dummy2 type dummy
    ip link set dev dummy0 netns TEST
    ip link set dev dummy1 netns TEST
    ip link set dev dummy2 netns TEST
    ip netns exec TEST ip addr add 192.168.1.1/24 dev dummy0
    ip netns exec TEST ip link set dummy0 up
    ip netns exec TEST ip addr add 192.168.1.2/24 dev dummy1
    ip netns exec TEST ip link set dummy1 up
    ip netns exec TEST ip addr add 192.168.1.3/24 dev dummy2
    ip netns exec TEST ip link set dummy2 up
    ip netns exec TEST sctp_test -H 192.168.1.2 -P 20002 -h 192.168.1.1 -p 20000 -s -B 192.168.1.3
    ip netns del TEST

    In 4.4 and 4.9 kernels this results to:
    [ 354.179591] unregister_netdevice: waiting for lo to become free. Usage count = 1
    [ 364.419674] unregister_netdevice: waiting for lo to become free. Usage count = 1
    [ 374.663664] unregister_netdevice: waiting for lo to become free. Usage count = 1
    [ 384.903717] unregister_netdevice: waiting for lo to become free. Usage count = 1
    [ 395.143724] unregister_netdevice: waiting for lo to become free. Usage count = 1
    [ 405.383645] unregister_netdevice: waiting for lo to become free. Usage count = 1
    ...

    Fixes: 410f03831 ("sctp: add routing output fallback")
    Fixes: 0ca50d12f ("sctp: fix src address selection if using secondary addresses")
    Signed-off-by: Tommi Rantala
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Tommi Rantala
     
  • [ Upstream commit 07f2c7ab6f8d0a7e7c5764c4e6cc9c52951b9d9c ]

    When SCTP makes INIT or INIT_ACK packet the total chunk length
    can exceed SCTP_MAX_CHUNK_LEN which leads to kernel panic when
    transmitting these packets, e.g. the crash on sending INIT_ACK:

    [ 597.804948] skbuff: skb_over_panic: text:00000000ffae06e4 len:120168
    put:120156 head:000000007aa47635 data:00000000d991c2de
    tail:0x1d640 end:0xfec0 dev:
    ...
    [ 597.976970] ------------[ cut here ]------------
    [ 598.033408] kernel BUG at net/core/skbuff.c:104!
    [ 600.314841] Call Trace:
    [ 600.345829]
    [ 600.371639] ? sctp_packet_transmit+0x2095/0x26d0 [sctp]
    [ 600.436934] skb_put+0x16c/0x200
    [ 600.477295] sctp_packet_transmit+0x2095/0x26d0 [sctp]
    [ 600.540630] ? sctp_packet_config+0x890/0x890 [sctp]
    [ 600.601781] ? __sctp_packet_append_chunk+0x3b4/0xd00 [sctp]
    [ 600.671356] ? sctp_cmp_addr_exact+0x3f/0x90 [sctp]
    [ 600.731482] sctp_outq_flush+0x663/0x30d0 [sctp]
    [ 600.788565] ? sctp_make_init+0xbf0/0xbf0 [sctp]
    [ 600.845555] ? sctp_check_transmitted+0x18f0/0x18f0 [sctp]
    [ 600.912945] ? sctp_outq_tail+0x631/0x9d0 [sctp]
    [ 600.969936] sctp_cmd_interpreter.isra.22+0x3be1/0x5cb0 [sctp]
    [ 601.041593] ? sctp_sf_do_5_1B_init+0x85f/0xc30 [sctp]
    [ 601.104837] ? sctp_generate_t1_cookie_event+0x20/0x20 [sctp]
    [ 601.175436] ? sctp_eat_data+0x1710/0x1710 [sctp]
    [ 601.233575] sctp_do_sm+0x182/0x560 [sctp]
    [ 601.284328] ? sctp_has_association+0x70/0x70 [sctp]
    [ 601.345586] ? sctp_rcv+0xef4/0x32f0 [sctp]
    [ 601.397478] ? sctp6_rcv+0xa/0x20 [sctp]
    ...

    Here the chunk size for INIT_ACK packet becomes too big, mostly
    because of the state cookie (INIT packet has large size with
    many address parameters), plus additional server parameters.

    Later this chunk causes the panic in skb_put_data():

    skb_packet_transmit()
    sctp_packet_pack()
    skb_put_data(nskb, chunk->skb->data, chunk->skb->len);

    'nskb' (head skb) was previously allocated with packet->size
    from u16 'chunk->chunk_hdr->length'.

    As suggested by Marcelo we should check the chunk's length in
    _sctp_make_chunk() before trying to allocate skb for it and
    discard a chunk if its size bigger than SCTP_MAX_CHUNK_LEN.

    Signed-off-by: Alexey Kodanev
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Alexey Kodanev
     

03 Mar, 2018

3 commits

  • [ Upstream commit c76f97c99ae6d26d14c7f0e50e074382bfbc9f98 ]

    Some sockopt handling functions were calculating the length of the
    buffer to be written to userspace and then calculating it again when
    actually writing the buffer, which could lead to some write not using
    an up-to-date length.

    This patch updates such places to just make use of the len variable.

    Also, replace some sizeof(type) to sizeof(var).

    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     
  • [ Upstream commit 5960cefab9df76600a1a7d4ff592c59e14616e88 ]

    Hangbin Liu reported that some sockopt calls could cause the kernel to log
    a warning on memory allocation failure if the user supplied a large optlen
    value. That is because some of them called memdup_user() without a ceiling
    on optlen, allowing it to try to allocate really large buffers.

    This patch adds a ceiling by limiting optlen to the maximum allowed that
    would still make sense for these sockopt.

    Reported-by: Hangbin Liu
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     
  • [ Upstream commit 5c468674d17056148da06218d4da5d04baf22eac ]

    Now when reneging events in sctp_ulpq_renege(), the variable freed
    could be increased by a __u16 value twice while freed is of __u16
    type. It means freed may overflow at the second addition.

    This patch is to fix it by using __u32 type for 'freed', while at
    it, also to remove 'if (chunk)' check, as all renege commands are
    generated in sctp_eat_data and it can't be NULL.

    Reported-by: Marcelo Ricardo Leitner
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

25 Feb, 2018

2 commits

  • [ Upstream commit d30fc5126efb0c33b7adf5966d3051db2c3d7721 ]

    Now outstanding_bytes is only increased when appending chunks into one
    packet and sending it at 1st time, while decreased when it is about to
    move into retransmit queue. It means outstanding_bytes value is already
    decreased for all chunks in retransmit queue.

    However sctp_prsctp_prune_sent is a common function to check the chunks
    in both transmitted and retransmit queue, it decrease outstanding_bytes
    when moving a chunk into abandoned queue from either of them.

    It could cause outstanding_bytes underflow, as it also decreases it's
    value for the chunks in retransmit queue.

    This patch fixes it by only updating outstanding_bytes for transmitted
    queue when pruning queues for prsctp prio policy, the same fix is also
    needed in sctp_check_transmitted.

    Fixes: 8dbdf1f5b09c ("sctp: implement prsctp PRIO policy")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit ecca8f88da5c4260cc2bccfefd2a24976704c366 upstream.

    Now in sctp_setsockopt_maxseg user_frag or frag_point can be set with
    val >= 8 and val = 8 means frag_point can even be less than SCTP_DEFAULT_MINSEGMENT.
    Then in sctp_datamsg_from_user(), when it's value is greater than cookie
    echo len and trying to bundle with cookie echo chunk, the first_len will
    overflow.

    The worse case is when it's value is equal as cookie echo len, first_len
    becomes 0, it will go into a dead loop for fragment later on. In Hangbin
    syzkaller testing env, oom was even triggered due to consecutive memory
    allocation in that loop.

    Besides, SCTP_MAX_CHUNK_LEN is the max size of the whole chunk, it should
    deduct the data header for frag_point or user_frag check.

    This patch does a proper check with SCTP_DEFAULT_MINSEGMENT subtracting
    the sctphdr and datahdr, SCTP_MAX_CHUNK_LEN subtracting datahdr when
    setting frag_point via sockopt. It also improves sctp_setsockopt_maxseg
    codes.

    Suggested-by: Marcelo Ricardo Leitner
    Reported-by: Hangbin Liu
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

04 Feb, 2018

3 commits

  • [ Upstream commit 52a395896a051a3d5c34fba67c324f69ec5e67c6 ]

    When doing asoc reset, if the sender of the response has already sent some
    chunk and increased asoc->next_tsn before the duplicate request comes, the
    response will use the old result with an incorrect sender next_tsn.

    Better than asoc->next_tsn, asoc->ctsn_ack_point can't be changed after
    the sender of the response has performed the asoc reset and before the
    peer has confirmed it, and it's value is still asoc->next_tsn original
    value minus 1.

    This patch sets sender next_tsn for the old result with ctsn_ack_point
    plus 1 when processing the duplicate request, to make sure the sender
    next_tsn value peer gets will be always right.

    Fixes: 692787cef651 ("sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 159f2a7456c6ae95c1e1a58e8b8ec65ef12d51cf ]

    Now when doing asoc reset, it cleans up sacked and abandoned queues
    by calling sctp_outq_free where it also cleans up unsent, retransmit
    and transmitted queues.

    It's safe for the sender of response, as these 3 queues are empty at
    that time. But when the receiver of response is doing the reset, the
    users may already enqueue some chunks into unsent during the time
    waiting the response, and these chunks should not be flushed.

    To void the chunks in it would be removed, it moves the queue into a
    temp list, then gets it back after sctp_outq_free is done.

    The patch also fixes some incorrect comments in
    sctp_process_strreset_tsnreq.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 5c6144a0eb5366ae07fc5059301b139338f39bbd ]

    As it says in rfc6525#section5.1.4, before sending the request,

    C2: The sender has either no outstanding TSNs or considers all
    outstanding TSNs abandoned.

    Prior to this patch, it tried to consider all outstanding TSNs abandoned
    by dropping all chunks in all outqs with sctp_outq_free (even including
    sacked, retransmit and transmitted queues) when doing this reset, which
    is too aggressive.

    To make it work gently, this patch will only allow the asoc reset when
    the sender has no outstanding TSNs by checking if unsent, transmitted
    and retransmit are all empty with sctp_outq_is_empty before sending
    and processing the request.

    Fixes: 692787cef651 ("sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

31 Jan, 2018

4 commits

  • [ Upstream commit 625637bf4afa45204bd87e4218645182a919485a ]

    After introducing sctp_stream structure, sctp uses stream->outcnt as the
    out stream nums instead of c.sinit_num_ostreams.

    However when users use sinit in cmsg, it only updates c.sinit_num_ostreams
    in sctp_sendmsg. At that moment, stream->outcnt is still using previous
    value. If it's value is not updated, the sinit_num_ostreams of sinit could
    not really work.

    This patch is to fix it by updating stream->outcnt and reiniting stream
    if stream outcnt has been change by sinit in sendmsg.

    Fixes: a83863174a61 ("sctp: prepare asoc stream for stream reconf")
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit 121d57af308d0cf943f08f4738d24d3966c38cd9 ]

    Validate gso_type during segmentation as SKB_GSO_DODGY sources
    may pass packets where the gso_type does not match the contents.

    Syzkaller was able to enter the SCTP gso handler with a packet of
    gso_type SKB_GSO_TCPV4.

    On entry of transport layer gso handlers, verify that the gso_type
    matches the transport protocol.

    Fixes: 90017accff61 ("sctp: Add GSO support")
    Link: http://lkml.kernel.org/r/
    Reported-by: syzbot+fee64147a25aecd48055@syzkaller.appspotmail.com
    Signed-off-by: Willem de Bruijn
    Acked-by: Jason Wang
    Reviewed-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Willem de Bruijn
     
  • [ Upstream commit a0ff660058b88d12625a783ce9e5c1371c87951f ]

    After commit cea0cc80a677 ("sctp: use the right sk after waking up from
    wait_buf sleep"), it may change to lock another sk if the asoc has been
    peeled off in sctp_wait_for_sndbuf.

    However, the asoc's new sk could be already closed elsewhere, as it's in
    the sendmsg context of the old sk that can't avoid the new sk's closing.
    If the sk's last one refcnt is held by this asoc, later on after putting
    this asoc, the new sk will be freed, while under it's own lock.

    This patch is to revert that commit, but fix the old issue by returning
    error under the old sk's lock.

    Fixes: cea0cc80a677 ("sctp: use the right sk after waking up from wait_buf sleep")
    Reported-by: syzbot+ac6ea7baa4432811eb50@syzkaller.appspotmail.com
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • [ Upstream commit c5006b8aa74599ce19104b31d322d2ea9ff887cc ]

    The check in sctp_sockaddr_af is not robust enough to forbid binding a
    v4mapped v6 addr on a v4 socket.

    The worse thing is that v4 socket's bind_verify would not convert this
    v4mapped v6 addr to a v4 addr. syzbot even reported a crash as the v4
    socket bound a v6 addr.

    This patch is to fix it by doing the common sa.sa_family check first,
    then AF_INET check for v4mapped v6 addrs.

    Fixes: 7dab83de50c7 ("sctp: Support ipv6only AF_INET6 sockets.")
    Reported-by: syzbot+7b7b518b1228d2743963@syzkaller.appspotmail.com
    Acked-by: Neil Horman
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

17 Jan, 2018

2 commits

  • [ Upstream commit b6c5734db07079c9410147b32407f2366d584e6c ]

    syzbot reported a hang involving SCTP, on which it kept flooding dmesg
    with the message:
    [ 246.742374] sctp: sctp_transport_update_pmtu: Reported pmtu 508 too
    low, using default minimum of 512

    That happened because whenever SCTP hits an ICMP Frag Needed, it tries
    to adjust to the new MTU and triggers an immediate retransmission. But
    it didn't consider the fact that MTUs smaller than the SCTP minimum MTU
    allowed (512) would not cause the PMTU to change, and issued the
    retransmission anyway (thus leading to another ICMP Frag Needed, and so
    on).

    As IPv4 (ip_rt_min_pmtu=556) and IPv6 (IPV6_MIN_MTU=1280) minimum MTU
    are higher than that, sctp_transport_update_pmtu() is changed to
    re-fetch the PMTU that got set after our request, and with that, detect
    if there was an actual change or not.

    The fix, thus, skips the immediate retransmission if the received ICMP
    resulted in no change, in the hope that SCTP will select another path.

    Note: The value being used for the minimum MTU (512,
    SCTP_DEFAULT_MINSEGMENT) is not right and instead it should be (576,
    SCTP_MIN_PMTU), but such change belongs to another patch.

    Changes from v1:
    - do not disable PMTU discovery, in the light of commit
    06ad391919b2 ("[SCTP] Don't disable PMTU discovery when mtu is small")
    and as suggested by Xin Long.
    - changed the way to break the rtx loop by detecting if the icmp
    resulted in a change or not
    Changes from v2:
    none

    See-also: https://lkml.org/lkml/2017/12/22/811
    Reported-by: syzbot
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     
  • [ Upstream commit cc35c3d1edf7a8373a1a5daa80a912dec96a9cd5 ]

    Currently, if PMTU discovery is disabled on a given transport, but the
    configured value is higher than the actual PMTU, it is likely that we
    will get some icmp Frag Needed. The issue is, if PMTU discovery is
    disabled, we won't update the information and will issue a
    retransmission immediately, which may very well trigger another ICMP,
    and another retransmission, leading to a loop.

    The fix is to simply not trigger immediate retransmissions if PMTU
    discovery is disabled on the given transport.

    Changes from v2:
    - updated stale comment, noticed by Xin Long

    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     

03 Jan, 2018

1 commit

  • [ Upstream commit 2342b8d95bcae5946e1b9b8d58645f37500ef2e7 ]

    Now in sctp_setsockopt_reset_streams, it only does the check
    optlen < sizeof(*params) for optlen. But it's not enough, as
    params->srs_number_streams should also match optlen.

    If the streams in params->srs_stream_list are less than stream
    nums in params->srs_number_streams, later when dereferencing
    the stream list, it could cause a slab-out-of-bounds crash, as
    reported by syzbot.

    This patch is to fix it by also checking the stream numbers in
    sctp_setsockopt_reset_streams to make sure at least it's not
    greater than the streams in the list.

    Fixes: 7f9d68ac944e ("sctp: implement sender-side procedures for SSN Reset Request Parameter")
    Reported-by: Dmitry Vyukov
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long