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

2 commits

  • [ 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
     
  • [ Upstream commit 8cb38a602478e9f806571f6920b0a3298aabf042 ]

    The patch(180d8cd942ce) replaces all uses of struct sock fields'
    memory_pressure, memory_allocated, sockets_allocated, and sysctl_mem
    to accessor macros. But the sockets_allocated field of sctp sock is
    not replaced at all. Then replace it now for unifying the code.

    Fixes: 180d8cd942ce ("foundations of per-cgroup memory pressure controlling.")
    Cc: Glauber Costa
    Signed-off-by: Tonghao Zhang
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Tonghao Zhang
     

25 Dec, 2017

1 commit

  • [ Upstream commit 1ae2eaaa229bc350b6f38fbf4ab9c873532aecfb ]

    As SCTP supports up to 65535 streams, that can lead to very large
    allocations in sctp_stream_init(). As Xin Long noticed, systems with
    small amounts of memory are more prone to not have enough memory and
    dump warnings on dmesg initiated by user actions. Thus, silence them.

    Also, if the reallocation of stream->out is not necessary, skip it and
    keep the memory we already have.

    Reported-by: Xin Long
    Tested-by: Xin Long
    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
     

17 Dec, 2017

1 commit

  • [ Upstream commit a8dd397903a6e57157f6265911f7d35681364427 ]

    Commit d04adf1b3551 ("sctp: reset owner sk for data chunks on out queues
    when migrating a sock") made a mistake that using 'list' as the param of
    list_for_each_entry to traverse the retransmit, sacked and abandoned
    queues, while chunks are using 'transmitted_list' to link into these
    queues.

    It could cause NULL dereference panic if there are chunks in any of these
    queues when peeling off one asoc.

    So use the chunk member 'transmitted_list' instead in this patch.

    Fixes: d04adf1b3551 ("sctp: reset owner sk for data chunks on out queues when migrating a sock")
    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
     

14 Dec, 2017

2 commits

  • [ Upstream commit cea0cc80a6777beb6eb643d4ad53690e1ad1d4ff ]

    Commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads
    sleeping on it") fixed the race between peeloff and wait sndbuf by
    checking waitqueue_active(&asoc->wait) in sctp_do_peeloff().

    But it actually doesn't work, as even if waitqueue_active returns false
    the waiting sndbuf thread may still not yet hold sk lock. After asoc is
    peeled off, sk is not asoc->base.sk any more, then to hold the old sk
    lock couldn't make assoc safe to access.

    This patch is to fix this by changing to hold the new sk lock if sk is
    not asoc->base.sk, meanwhile, also set the sk in sctp_sendmsg with the
    new sk.

    With this fix, there is no more race between peeloff and waitbuf, the
    check 'waitqueue_active' in sctp_do_peeloff can be removed.

    Thanks Marcelo and Neil for making this clear.

    v1->v2:
    fix it by changing to lock the new sock instead of adding a flag in asoc.

    Suggested-by: Neil Horman
    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
     
  • [ Upstream commit ca3af4dd28cff4e7216e213ba3b671fbf9f84758 ]

    Now in sctp_sendmsg sctp_wait_for_sndbuf could schedule out without
    holding sock sk. It means the current asoc can be freed elsewhere,
    like when receiving an abort packet.

    If the asoc is just created in sctp_sendmsg and sctp_wait_for_sndbuf
    returns err, the asoc will be freed again due to new_asoc is not nil.
    An use-after-free issue would be triggered by this.

    This patch is to fix it by setting new_asoc with nil if the asoc is
    already dead when cpu schedules back, so that it will not be freed
    again in sctp_sendmsg.

    v1->v2:
    set new_asoc as nil in sctp_sendmsg instead of sctp_wait_for_sndbuf.

    Suggested-by: Neil Horman
    Reported-by: Dmitry Vyukov
    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
     

24 Nov, 2017

1 commit

  • [ Upstream commit 7c8a61d9ee1df0fb4747879fa67a99614eb62fec ]

    Alexandar Potapenko while testing the kernel with KMSAN and syzkaller
    discovered that in some configurations sctp would leak 4 bytes of
    kernel stack.

    Working with his reproducer I discovered that those 4 bytes that
    are leaked is the scope id of an ipv6 address returned by recvmsg.

    With a little code inspection and a shrewd guess I discovered that
    sctp_inet6_skb_msgname only initializes the scope_id field for link
    local ipv6 addresses to the interface index the link local address
    pertains to instead of initializing the scope_id field for all ipv6
    addresses.

    That is almost reasonable as scope_id's are meaniningful only for link
    local addresses. Set the scope_id in all other cases to 0 which is
    not a valid interface index to make it clear there is nothing useful
    in the scope_id field.

    There should be no danger of breaking userspace as the stack leak
    guaranteed that previously meaningless random data was being returned.

    Fixes: 372f525b495c ("SCTP: Resync with LKSCTP tree.")
    History-tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
    Reported-by: Alexander Potapenko
    Tested-by: Alexander Potapenko
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric W. Biederman
     

03 Nov, 2017

1 commit

  • …el/git/gregkh/driver-core

    Pull initial SPDX identifiers from Greg KH:
    "License cleanup: add SPDX license identifiers to some files

    Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the
    'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally
    binding shorthand, which can be used instead of the full boiler plate
    text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart
    and Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset
    of the use cases:

    - file had no licensing information it it.

    - file was a */uapi/* one with no licensing information in it,

    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to
    license had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied
    to a file was done in a spreadsheet of side by side results from of
    the output of two independent scanners (ScanCode & Windriver)
    producing SPDX tag:value files created by Philippe Ombredanne.
    Philippe prepared the base worksheet, and did an initial spot review
    of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537
    files assessed. Kate Stewart did a file by file comparison of the
    scanner results in the spreadsheet to determine which SPDX license
    identifier(s) to be applied to the file. She confirmed any
    determination that was not immediately clear with lawyers working with
    the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:

    - Files considered eligible had to be source code files.

    - Make and config files were included as candidates if they contained
    >5 lines of source

    - File already had some variant of a license header in it (even if <5
    lines).

    All documentation files were explicitly excluded.

    The following heuristics were used to determine which SPDX license
    identifiers to apply.

    - when both scanners couldn't find any license traces, file was
    considered to have no license information in it, and the top level
    COPYING file license applied.

    For non */uapi/* files that summary was:

    SPDX license identifier # files
    ---------------------------------------------------|-------
    GPL-2.0 11139

    and resulted in the first patch in this series.

    If that file was a */uapi/* path one, it was "GPL-2.0 WITH
    Linux-syscall-note" otherwise it was "GPL-2.0". Results of that
    was:

    SPDX license identifier # files
    ---------------------------------------------------|-------
    GPL-2.0 WITH Linux-syscall-note 930

    and resulted in the second patch in this series.

    - if a file had some form of licensing information in it, and was one
    of the */uapi/* ones, it was denoted with the Linux-syscall-note if
    any GPL family license was found in the file or had no licensing in
    it (per prior point). Results summary:

    SPDX license identifier # files
    ---------------------------------------------------|------
    GPL-2.0 WITH Linux-syscall-note 270
    GPL-2.0+ WITH Linux-syscall-note 169
    ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
    ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
    LGPL-2.1+ WITH Linux-syscall-note 15
    GPL-1.0+ WITH Linux-syscall-note 14
    ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
    LGPL-2.0+ WITH Linux-syscall-note 4
    LGPL-2.1 WITH Linux-syscall-note 3
    ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
    ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1

    and that resulted in the third patch in this series.

    - when the two scanners agreed on the detected license(s), that
    became the concluded license(s).

    - when there was disagreement between the two scanners (one detected
    a license but the other didn't, or they both detected different
    licenses) a manual inspection of the file occurred.

    - In most cases a manual inspection of the information in the file
    resulted in a clear resolution of the license that should apply
    (and which scanner probably needed to revisit its heuristics).

    - When it was not immediately clear, the license identifier was
    confirmed with lawyers working with the Linux Foundation.

    - If there was any question as to the appropriate license identifier,
    the file was flagged for further research and to be revisited later
    in time.

    In total, over 70 hours of logged manual review was done on the
    spreadsheet to determine the SPDX license identifiers to apply to the
    source files by Kate, Philippe, Thomas and, in some cases,
    confirmation by lawyers working with the Linux Foundation.

    Kate also obtained a third independent scan of the 4.13 code base from
    FOSSology, and compared selected files where the other two scanners
    disagreed against that SPDX file, to see if there was new insights.
    The Windriver scanner is based on an older version of FOSSology in
    part, so they are related.

    Thomas did random spot checks in about 500 files from the spreadsheets
    for the uapi headers and agreed with SPDX license identifier in the
    files he inspected. For the non-uapi files Thomas did random spot
    checks in about 15000 files.

    In initial set of patches against 4.14-rc6, 3 files were found to have
    copy/paste license identifier errors, and have been fixed to reflect
    the correct identifier.

    Additionally Philippe spent 10 hours this week doing a detailed manual
    inspection and review of the 12,461 patched files from the initial
    patch version early this week with:

    - a full scancode scan run, collecting the matched texts, detected
    license ids and scores

    - reviewing anything where there was a license detected (about 500+
    files) to ensure that the applied SPDX license was correct

    - reviewing anything where there was no detection but the patch
    license was not GPL-2.0 WITH Linux-syscall-note to ensure that the
    applied SPDX license was correct

    This produced a worksheet with 20 files needing minor correction. This
    worksheet was then exported into 3 different .csv files for the
    different types of files to be modified.

    These .csv files were then reviewed by Greg. Thomas wrote a script to
    parse the csv files and add the proper SPDX tag to the file, in the
    format that the file expected. This script was further refined by Greg
    based on the output to detect more types of files automatically and to
    distinguish between header and source .c files (which need different
    comment types.) Finally Greg ran the script using the .csv files to
    generate the patches.

    Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
    Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"

    * tag 'spdx_identifiers-4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
    License cleanup: add SPDX license identifier to uapi header files with a license
    License cleanup: add SPDX license identifier to uapi header files with no license
    License cleanup: add SPDX GPL-2.0 license identifier to files with no license

    Linus Torvalds
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

29 Oct, 2017

1 commit

  • These warnings were found by running 'make C=2 M=net/sctp/'.
    They are there since very beginning.

    Note after this patch, there still one warning left in
    sctp_outq_flush():
    sctp_chunk_fail(chunk, SCTP_ERROR_INV_STRM)

    Since it has been moved to sctp_stream_outq_migrate on net-next,
    to avoid the extra job when merging net-next to net, I will post
    the fix for it after the merging is done.

    Reported-by: Eric Dumazet
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long