Skip to content
Snippets Groups Projects
  1. Jan 01, 2022
    • Haimin Zhang's avatar
      net ticp:fix a kernel-infoleak in __tipc_sendmsg() · d6d86830
      Haimin Zhang authored
      
      struct tipc_socket_addr.ref has a 4-byte hole,and __tipc_getname() currently
      copying it to user space,causing kernel-infoleak.
      
      BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:121 [inline]
      BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:121 [inline] lib/usercopy.c:33
      BUG: KMSAN: kernel-infoleak in _copy_to_user+0x1c9/0x270 lib/usercopy.c:33 lib/usercopy.c:33
       instrument_copy_to_user include/linux/instrumented.h:121 [inline]
       instrument_copy_to_user include/linux/instrumented.h:121 [inline] lib/usercopy.c:33
       _copy_to_user+0x1c9/0x270 lib/usercopy.c:33 lib/usercopy.c:33
       copy_to_user include/linux/uaccess.h:209 [inline]
       copy_to_user include/linux/uaccess.h:209 [inline] net/socket.c:287
       move_addr_to_user+0x3f6/0x600 net/socket.c:287 net/socket.c:287
       __sys_getpeername+0x470/0x6b0 net/socket.c:1987 net/socket.c:1987
       __do_sys_getpeername net/socket.c:1997 [inline]
       __se_sys_getpeername net/socket.c:1994 [inline]
       __do_sys_getpeername net/socket.c:1997 [inline] net/socket.c:1994
       __se_sys_getpeername net/socket.c:1994 [inline] net/socket.c:1994
       __x64_sys_getpeername+0xda/0x120 net/socket.c:1994 net/socket.c:1994
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_x64 arch/x86/entry/common.c:51 [inline] arch/x86/entry/common.c:82
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Uninit was stored to memory at:
       tipc_getname+0x575/0x5e0 net/tipc/socket.c:757 net/tipc/socket.c:757
       __sys_getpeername+0x3b3/0x6b0 net/socket.c:1984 net/socket.c:1984
       __do_sys_getpeername net/socket.c:1997 [inline]
       __se_sys_getpeername net/socket.c:1994 [inline]
       __do_sys_getpeername net/socket.c:1997 [inline] net/socket.c:1994
       __se_sys_getpeername net/socket.c:1994 [inline] net/socket.c:1994
       __x64_sys_getpeername+0xda/0x120 net/socket.c:1994 net/socket.c:1994
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_x64 arch/x86/entry/common.c:51 [inline] arch/x86/entry/common.c:82
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Uninit was stored to memory at:
       msg_set_word net/tipc/msg.h:212 [inline]
       msg_set_destport net/tipc/msg.h:619 [inline]
       msg_set_word net/tipc/msg.h:212 [inline] net/tipc/socket.c:1486
       msg_set_destport net/tipc/msg.h:619 [inline] net/tipc/socket.c:1486
       __tipc_sendmsg+0x44fa/0x5890 net/tipc/socket.c:1486 net/tipc/socket.c:1486
       tipc_sendmsg+0xeb/0x140 net/tipc/socket.c:1402 net/tipc/socket.c:1402
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg net/socket.c:724 [inline]
       sock_sendmsg_nosec net/socket.c:704 [inline] net/socket.c:2409
       sock_sendmsg net/socket.c:724 [inline] net/socket.c:2409
       ____sys_sendmsg+0xe11/0x12c0 net/socket.c:2409 net/socket.c:2409
       ___sys_sendmsg net/socket.c:2463 [inline]
       ___sys_sendmsg net/socket.c:2463 [inline] net/socket.c:2492
       __sys_sendmsg+0x704/0x840 net/socket.c:2492 net/socket.c:2492
       __do_sys_sendmsg net/socket.c:2501 [inline]
       __se_sys_sendmsg net/socket.c:2499 [inline]
       __do_sys_sendmsg net/socket.c:2501 [inline] net/socket.c:2499
       __se_sys_sendmsg net/socket.c:2499 [inline] net/socket.c:2499
       __x64_sys_sendmsg+0xe2/0x120 net/socket.c:2499 net/socket.c:2499
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_x64 arch/x86/entry/common.c:51 [inline] arch/x86/entry/common.c:82
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Local variable skaddr created at:
       __tipc_sendmsg+0x2d0/0x5890 net/tipc/socket.c:1419 net/tipc/socket.c:1419
       tipc_sendmsg+0xeb/0x140 net/tipc/socket.c:1402 net/tipc/socket.c:1402
      
      Bytes 4-7 of 16 are uninitialized
      Memory access of size 16 starts at ffff888113753e00
      Data copied to user address 0000000020000280
      
      Reported-by: default avatar <syzbot+cdbd40e0c3ca02cae3b7@syzkaller.appspotmail.com>
      Signed-off-by: default avatarHaimin Zhang <tcs_kernel@tencent.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Link: https://lore.kernel.org/r/1640918123-14547-1-git-send-email-tcs.kernel@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d6d86830
  2. Sep 13, 2021
    • Hoang Le's avatar
      tipc: increase timeout in tipc_sk_enqueue() · f4bb62e6
      Hoang Le authored
      
      In tipc_sk_enqueue() we use hardcoded 2 jiffies to extract
      socket buffer from generic queue to particular socket.
      The 2 jiffies is too short in case there are other high priority
      tasks get CPU cycles for multiple jiffies update. As result, no
      buffer could be enqueued to particular socket.
      
      To solve this, we switch to use constant timeout 20msecs.
      Then, the function will be expired between 2 jiffies (CONFIG_100HZ)
      and 20 jiffies (CONFIG_1000HZ).
      
      Fixes: c637c103 ("tipc: resolve race problem at unicast message reception")
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarHoang Le <hoang.h.le@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f4bb62e6
  3. Sep 03, 2021
  4. Aug 16, 2021
  5. Jul 25, 2021
    • Xin Long's avatar
      tipc: fix an use-after-free issue in tipc_recvmsg · cc19862f
      Xin Long authored
      
      syzbot reported an use-after-free crash:
      
        BUG: KASAN: use-after-free in tipc_recvmsg+0xf77/0xf90 net/tipc/socket.c:1979
        Call Trace:
         tipc_recvmsg+0xf77/0xf90 net/tipc/socket.c:1979
         sock_recvmsg_nosec net/socket.c:943 [inline]
         sock_recvmsg net/socket.c:961 [inline]
         sock_recvmsg+0xca/0x110 net/socket.c:957
         tipc_conn_rcv_from_sock+0x162/0x2f0 net/tipc/topsrv.c:398
         tipc_conn_recv_work+0xeb/0x190 net/tipc/topsrv.c:421
         process_one_work+0x98d/0x1630 kernel/workqueue.c:2276
         worker_thread+0x658/0x11f0 kernel/workqueue.c:2422
      
      As Hoang pointed out, it was caused by skb_cb->bytes_read still accessed
      after calling tsk_advance_rx_queue() to free the skb in tipc_recvmsg().
      
      This patch is to fix it by accessing skb_cb->bytes_read earlier than
      calling tsk_advance_rx_queue().
      
      Fixes: f4919ff5 ("tipc: keep the skb in rcv queue until the whole data is read")
      Reported-by: default avatar <syzbot+e6741b97d5552f97c24d@syzkaller.appspotmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cc19862f
  6. Jul 23, 2021
  7. Jul 17, 2021
    • Xin Long's avatar
      tipc: keep the skb in rcv queue until the whole data is read · f4919ff5
      Xin Long authored
      
      Currently, when userspace reads a datagram with a buffer that is
      smaller than this datagram, the data will be truncated and only
      part of it can be received by users. It doesn't seem right that
      users don't know the datagram size and have to use a huge buffer
      to read it to avoid the truncation.
      
      This patch to fix it by keeping the skb in rcv queue until the
      whole data is read by users. Only the last msg of the datagram
      will be marked with MSG_EOR, just as TCP/SCTP does.
      
      Note that this will work as above only when MSG_EOR is set in the
      flags parameter of recvmsg(), so that it won't break any old user
      applications.
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f4919ff5
  8. Jun 10, 2021
  9. Jun 03, 2021
  10. May 14, 2021
  11. Mar 29, 2021
  12. Mar 17, 2021
  13. Dec 01, 2020
    • Randy Dunlap's avatar
      net/tipc: fix all function Return: notation · 637b77fd
      Randy Dunlap authored
      
      Fix Return: kernel-doc notation in all net/tipc/ source files.
      Also keep ReST list notation intact for output formatting.
      Fix a few typos in comments.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      637b77fd
    • Randy Dunlap's avatar
      net/tipc: fix socket.c kernel-doc · f172f4b8
      Randy Dunlap authored
      
      Fix socket.c kernel-doc warnings in preparation for adding to the
      networking docbook.
      
      Also, for rcvbuf_limit(), use bullet notation so that the lines do
      not run together.
      
      ../net/tipc/socket.c:130: warning: Function parameter or member 'cong_links' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'probe_unacked' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'snd_win' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'peer_caps' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'rcv_win' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'group' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'oneway' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'nagle_start' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'snd_backlog' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'msg_acc' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'pkt_cnt' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'expect_ack' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'nodelay' not described in 'tipc_sock'
      ../net/tipc/socket.c:130: warning: Function parameter or member 'group_is_open' not described in 'tipc_sock'
      ../net/tipc/socket.c:267: warning: Function parameter or member 'sk' not described in 'tsk_advance_rx_queue'
      ../net/tipc/socket.c:295: warning: Function parameter or member 'sk' not described in 'tsk_rej_rx_queue'
      ../net/tipc/socket.c:295: warning: Function parameter or member 'error' not described in 'tsk_rej_rx_queue'
      ../net/tipc/socket.c:894: warning: Function parameter or member 'tsk' not described in 'tipc_send_group_msg'
      ../net/tipc/socket.c:1187: warning: Function parameter or member 'net' not described in 'tipc_sk_mcast_rcv'
      ../net/tipc/socket.c:1323: warning: Function parameter or member 'inputq' not described in 'tipc_sk_conn_proto_rcv'
      ../net/tipc/socket.c:1323: warning: Function parameter or member 'xmitq' not described in 'tipc_sk_conn_proto_rcv'
      ../net/tipc/socket.c:1885: warning: Function parameter or member 'sock' not described in 'tipc_recvmsg'
      ../net/tipc/socket.c:1993: warning: Function parameter or member 'sock' not described in 'tipc_recvstream'
      ../net/tipc/socket.c:2313: warning: Function parameter or member 'xmitq' not described in 'tipc_sk_filter_rcv'
      ../net/tipc/socket.c:2404: warning: Function parameter or member 'xmitq' not described in 'tipc_sk_enqueue'
      ../net/tipc/socket.c:2456: warning: Function parameter or member 'net' not described in 'tipc_sk_rcv'
      ../net/tipc/socket.c:2693: warning: Function parameter or member 'kern' not described in 'tipc_accept'
      ../net/tipc/socket.c:3816: warning: Excess function parameter 'sysctl_tipc_sk_filter' description in 'tipc_sk_filtering'
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f172f4b8
    • Randy Dunlap's avatar
      net/tipc: fix various kernel-doc warnings · 5fcb7d47
      Randy Dunlap authored
      
      kernel-doc and Sphinx fixes to eliminate lots of warnings
      in preparation for adding to the networking docbook.
      
      ../net/tipc/crypto.c:57: warning: cannot understand function prototype: 'enum '
      ../net/tipc/crypto.c:69: warning: cannot understand function prototype: 'enum '
      ../net/tipc/crypto.c:130: warning: Function parameter or member 'tfm' not described in 'tipc_tfm'
      ../net/tipc/crypto.c:130: warning: Function parameter or member 'list' not described in 'tipc_tfm'
      ../net/tipc/crypto.c:172: warning: Function parameter or member 'stat' not described in 'tipc_crypto_stats'
      ../net/tipc/crypto.c:232: warning: Function parameter or member 'flags' not described in 'tipc_crypto'
      ../net/tipc/crypto.c:329: warning: Function parameter or member 'ukey' not described in 'tipc_aead_key_validate'
      ../net/tipc/crypto.c:329: warning: Function parameter or member 'info' not described in 'tipc_aead_key_validate'
      ../net/tipc/crypto.c:482: warning: Function parameter or member 'aead' not described in 'tipc_aead_tfm_next'
      ../net/tipc/trace.c:43: warning: cannot understand function prototype: 'unsigned long sysctl_tipc_sk_filter[5] __read_mostly = '
      
      Documentation/networking/tipc:57: ../net/tipc/msg.c:584: WARNING: Unexpected indentation.
      Documentation/networking/tipc:63: ../net/tipc/name_table.c:536: WARNING: Unexpected indentation.
      Documentation/networking/tipc:63: ../net/tipc/name_table.c:537: WARNING: Block quote ends without a blank line; unexpected unindent.
      Documentation/networking/tipc:78: ../net/tipc/socket.c:3809: WARNING: Unexpected indentation.
      Documentation/networking/tipc:78: ../net/tipc/socket.c:3807: WARNING: Inline strong start-string without end-string.
      Documentation/networking/tipc:72: ../net/tipc/node.c:904: WARNING: Unexpected indentation.
      Documentation/networking/tipc:39: ../net/tipc/crypto.c:97: WARNING: Block quote ends without a blank line; unexpected unindent.
      Documentation/networking/tipc:39: ../net/tipc/crypto.c:98: WARNING: Block quote ends without a blank line; unexpected unindent.
      Documentation/networking/tipc:39: ../net/tipc/crypto.c:141: WARNING: Inline strong start-string without end-string.
      
      ../net/tipc/discover.c:82: warning: Function parameter or member 'skb' not described in 'tipc_disc_init_msg'
      
      ../net/tipc/msg.c:69: warning: Function parameter or member 'gfp' not described in 'tipc_buf_acquire'
      ../net/tipc/msg.c:382: warning: Function parameter or member 'offset' not described in 'tipc_msg_build'
      ../net/tipc/msg.c:708: warning: Function parameter or member 'net' not described in 'tipc_msg_lookup_dest'
      
      ../net/tipc/subscr.c:65: warning: Function parameter or member 'seq' not described in 'tipc_sub_check_overlap'
      ../net/tipc/subscr.c:65: warning: Function parameter or member 'found_lower' not described in 'tipc_sub_check_overlap'
      ../net/tipc/subscr.c:65: warning: Function parameter or member 'found_upper' not described in 'tipc_sub_check_overlap'
      
      ../net/tipc/udp_media.c:75: warning: Function parameter or member 'proto' not described in 'udp_media_addr'
      ../net/tipc/udp_media.c:75: warning: Function parameter or member 'port' not described in 'udp_media_addr'
      ../net/tipc/udp_media.c:75: warning: Function parameter or member 'ipv4' not described in 'udp_media_addr'
      ../net/tipc/udp_media.c:75: warning: Function parameter or member 'ipv6' not described in 'udp_media_addr'
      ../net/tipc/udp_media.c:98: warning: Function parameter or member 'rcast' not described in 'udp_bearer'
      
      Also fixed a typo of "duest" to "dest".
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5fcb7d47
  14. Nov 28, 2020
  15. Oct 30, 2020
    • Jon Maloy's avatar
      tipc: add stricter control of reserved service types · 72671b35
      Jon Maloy authored
      
      TIPC reserves 64 service types for current and future internal use.
      Therefore, the bind() function is meant to block regular user sockets
      from being bound to these values, while it should let through such
      bindings from internal users.
      
      However, since we at the design moment saw no way to distinguish
      between regular and internal users the filter function ended up
      with allowing all bindings of the reserved types which were really
      in use ([0,1]), and block all the rest ([2,63]).
      
      This is risky, since a regular user may bind to the service type
      representing the topology server (TIPC_TOP_SRV == 1) or the one used
      for indicating neighboring node status (TIPC_CFG_SRV == 0), and wreak
      havoc for users of those services, i.e., most users.
      
      The reality is however that TIPC_CFG_SRV never is bound through the
      bind() function, since it doesn't represent a regular socket, and
      TIPC_TOP_SRV can also be made to bypass the checks in tipc_bind()
      by introducing a different entry function, tipc_sk_bind().
      
      It should be noted that although this is a change of the API semantics,
      there is no risk we will break any currently working applications by
      doing this. Any application trying to bind to the values in question
      would be badly broken from the outset, so there is no chance we would
      find any such applications in real-world production systems.
      
      v2: Added warning printout when a user is blocked from binding,
          as suggested by Jakub Kicinski
      
      Acked-by: default avatarYung Xue <ying.xue@windriver.com>
      Signed-off-by: default avatarJon Maloy <jmaloy@redhat.com>
      Link: https://lore.kernel.org/r/20201030012938.489557-1-jmaloy@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      72671b35
  16. Sep 18, 2020
  17. Sep 10, 2020
    • Tetsuo Handa's avatar
      tipc: fix shutdown() of connection oriented socket · a4b5cc9e
      Tetsuo Handa authored
      
      I confirmed that the problem fixed by commit 2a63866c ("tipc: fix
      shutdown() of connectionless socket") also applies to stream socket.
      
      ----------
      #include <sys/socket.h>
      #include <unistd.h>
      #include <sys/wait.h>
      
      int main(int argc, char *argv[])
      {
              int fds[2] = { -1, -1 };
              socketpair(PF_TIPC, SOCK_STREAM /* or SOCK_DGRAM */, 0, fds);
              if (fork() == 0)
                      _exit(read(fds[0], NULL, 1));
              shutdown(fds[0], SHUT_RDWR); /* This must make read() return. */
              wait(NULL); /* To be woken up by _exit(). */
              return 0;
      }
      ----------
      
      Since shutdown(SHUT_RDWR) should affect all processes sharing that socket,
      unconditionally setting sk->sk_shutdown to SHUTDOWN_MASK will be the right
      behavior.
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Acked-by: default avatarYing Xue <ying.xue@windriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a4b5cc9e
  18. Sep 02, 2020
    • Tetsuo Handa's avatar
      tipc: fix shutdown() of connectionless socket · 2a63866c
      Tetsuo Handa authored
      syzbot is reporting hung task at nbd_ioctl() [1], for there are two
      problems regarding TIPC's connectionless socket's shutdown() operation.
      
      ----------
      #include <fcntl.h>
      #include <sys/socket.h>
      #include <sys/ioctl.h>
      #include <linux/nbd.h>
      #include <unistd.h>
      
      int main(int argc, char *argv[])
      {
              const int fd = open("/dev/nbd0", 3);
              alarm(5);
              ioctl(fd, NBD_SET_SOCK, socket(PF_TIPC, SOCK_DGRAM, 0));
              ioctl(fd, NBD_DO_IT, 0); /* To be interrupted by SIGALRM. */
              return 0;
      }
      ----------
      
      One problem is that wait_for_completion() from flush_workqueue() from
      nbd_start_device_ioctl() from nbd_ioctl() cannot be completed when
      nbd_start_device_ioctl() received a signal at wait_event_interruptible(),
      for tipc_shutdown() from kernel_sock_shutdown(SHUT_RDWR) from
      nbd_mark_nsock_dead() from sock_shutdown() from nbd_start_device_ioctl()
      is failing to wake up a WQ thread sleeping at wait_woken() from
      tipc_wait_for_rcvmsg() from sock_recvmsg() from sock_xmit() from
      nbd_read_stat() from recv_work() scheduled by nbd_start_device() from
      nbd_start_device_ioctl(). Fix this problem by always invoking
      sk->sk_state_change() (like inet_shutdown() does) when tipc_shutdown() is
      called.
      
      The other problem is that tipc_wait_for_rcvmsg() cannot return when
      tipc_shutdown() is called, for tipc_shutdown() sets sk->sk_shutdown to
      SEND_SHUTDOWN (despite "how" is SHUT_RDWR) while tipc_wait_for_rcvmsg()
      needs sk->sk_shutdown set to RCV_SHUTDOWN or SHUTDOWN_MASK. Fix this
      problem by setting sk->sk_shutdown to SHUTDOWN_MASK (like inet_shutdown()
      does) when the socket is connectionless.
      
      [1] https://syzkaller.appspot.com/bug?id=3fe51d307c1f0a845485cf1798aa059d12bf18b2
      
      
      
      Reported-by: default avatarsyzbot <syzbot+e36f41d207137b5d12f7@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2a63866c
  19. Aug 31, 2020
  20. Aug 23, 2020
  21. Aug 18, 2020
  22. Jul 24, 2020
  23. Jul 14, 2020
  24. Jun 11, 2020
    • Tuong Lien's avatar
      tipc: fix kernel WARNING in tipc_msg_append() · c9aa81fa
      Tuong Lien authored
      
      syzbot found the following issue:
      
      WARNING: CPU: 0 PID: 6808 at include/linux/thread_info.h:150 check_copy_size include/linux/thread_info.h:150 [inline]
      WARNING: CPU: 0 PID: 6808 at include/linux/thread_info.h:150 copy_from_iter include/linux/uio.h:144 [inline]
      WARNING: CPU: 0 PID: 6808 at include/linux/thread_info.h:150 tipc_msg_append+0x49a/0x5e0 net/tipc/msg.c:242
      Kernel panic - not syncing: panic_on_warn set ...
      
      This happens after commit 5e9eeccc ("tipc: fix NULL pointer
      dereference in streaming") that tried to build at least one buffer even
      when the message data length is zero... However, it now exposes another
      bug that the 'mss' can be zero and the 'cpy' will be negative, thus the
      above kernel WARNING will appear!
      The zero value of 'mss' is never expected because it means Nagle is not
      enabled for the socket (actually the socket type was 'SOCK_SEQPACKET'),
      so the function 'tipc_msg_append()' must not be called at all. But that
      was in this particular case since the message data length was zero, and
      the 'send <= maxnagle' check became true.
      
      We resolve the issue by explicitly checking if Nagle is enabled for the
      socket, i.e. 'maxnagle != 0' before calling the 'tipc_msg_append()'. We
      also reinforce the function to against such a negative values if any.
      
      Reported-by: default avatar <syzbot+75139a7d2605236b0b7f@syzkaller.appspotmail.com>
      Fixes: c0bceb97 ("tipc: add smart nagle feature")
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c9aa81fa
  25. Jun 01, 2020
Loading