1. 31 Mar, 2023 3 commits
    • Ziyang Xuan's avatar
      net: qrtr: Fix a refcount bug in qrtr_recvmsg() · 44d80732
      Ziyang Xuan authored
      Syzbot reported a bug as following:
      
      refcount_t: addition on 0; use-after-free.
      ...
      RIP: 0010:refcount_warn_saturate+0x17c/0x1f0 lib/refcount.c:25
      ...
      Call Trace:
       <TASK>
       __refcount_add include/linux/refcount.h:199 [inline]
       __refcount_inc include/linux/refcount.h:250 [inline]
       refcount_inc include/linux/refcount.h:267 [inline]
       kref_get include/linux/kref.h:45 [inline]
       qrtr_node_acquire net/qrtr/af_qrtr.c:202 [inline]
       qrtr_node_lookup net/qrtr/af_qrtr.c:398 [inline]
       qrtr_send_resume_tx net/qrtr/af_qrtr.c:1003 [inline]
       qrtr_recvmsg+0x85f/0x990 net/qrtr/af_qrtr.c:1070
       sock_recvmsg_nosec net/socket.c:1017 [inline]
       sock_recvmsg+0xe2/0x160 net/socket.c:1038
       qrtr_ns_worker+0x170/0x1700 net/qrtr/ns.c:688
       process_one_work+0x991/0x15c0 kernel/workqueue.c:2390
       worker_thread+0x669/0x1090 kernel/workqueue.c:2537
      
      It occurs in the concurrent scenario of qrtr_recvmsg() and
      qrtr_endpoint_unregister() as following:
      
      	cpu0					cpu1
      qrtr_recvmsg				qrtr_endpoint_unregister
      qrtr_send_resume_tx			qrtr_node_release
      qrtr_node_lookup			mutex_lock(&qrtr_node_lock)
      spin_lock_irqsave(&qrtr_nodes_lock, )	refcount_dec_and_test(&node->ref) [node->ref == 0]
      radix_tree_lookup [node != NULL]	__qrtr_node_release
      qrtr_node_acquire			spin_lock_irqsave(&qrtr_nodes_lock, )
      kref_get(&node->ref) [WARNING]		...
      					mutex_unlock(&qrtr_node_lock)
      
      Use qrtr_node_lock to protect qrtr_node_lookup() implementation, this
      is actually improving the protection of node reference.
      
      Fixes: 0a7e0d0e ("net: qrtr: Migrate node lookup tree to spinlock")
      Reported-by: syzbot+a7492efaa5d61b51db23@syzkaller.appspotmail.com
      Link: https://syzkaller.appspot.com/bug?extid=a7492efaa5d61b51db23Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      44d80732
    • Bobby Eshleman's avatar
      virtio/vsock: fix leaks due to missing skb owner · f9d2b1e1
      Bobby Eshleman authored
      This patch sets the skb owner in the recv and send path for virtio.
      
      For the send path, this solves the leak caused when
      virtio_transport_purge_skbs() finds skb->sk is always NULL and therefore
      never matches it with the current socket. Setting the owner upon
      allocation fixes this.
      
      For the recv path, this ensures correctness of accounting and also
      correct transfer of ownership in vsock_loopback (when skbs are sent from
      one socket and received by another).
      
      Fixes: 71dc9ec9 ("virtio/vsock: replace virtio_vsock_pkt with sk_buff")
      Signed-off-by: default avatarBobby Eshleman <bobby.eshleman@bytedance.com>
      Reported-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Link: https://lore.kernel.org/all/ZCCbATwov4U+GBUv@pop-os.localdomain/Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f9d2b1e1
    • Jakub Kicinski's avatar
      Merge tag 'wireless-2023-03-30' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless · 6b36d68c
      Jakub Kicinski authored
      Johannes Berg says:
      
      ====================
      Just a few fixes:
      
       * fix size calculation for EHT element to put into SKBs
       * remove erroneous pre-RCU calls for drivers not using sta_state calls
       * fix mesh forwarding and non-forwarding RX
       * fix mesh flow dissection
       * fix a potential NULL dereference on A-MSDU RX w/o station
       * make two variable non-static that really shouldn't be static
      
      * tag 'wireless-2023-03-30' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless:
        wifi: mac80211: fix invalid drv_sta_pre_rcu_remove calls for non-uploaded sta
        wifi: mac80211: fix flow dissection for forwarded packets
        wifi: mac80211: fix mesh forwarding
        wifi: mac80211: fix receiving mesh packets in forwarding=0 networks
        wifi: mac80211: fix the size calculation of ieee80211_ie_len_eht_cap()
        wifi: mac80211: fix potential null pointer dereference
        wifi: mac80211: drop bogus static keywords in A-MSDU rx
      ====================
      
      Link: https://lore.kernel.org/r/20230330203313.919164-1-johannes@sipsolutions.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6b36d68c
  2. 30 Mar, 2023 37 commits