lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 1 Feb 2022 15:27:32 +0800
From:   Jia-Ju Bai <baijiaju1990@...il.com>
To:     jasowang@...hat.com
Cc:     kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org,
        netdev@...r.kernel.org, linux-kernel <linux-kernel@...r.kernel.org>
Subject: [BUG] vhost: two possible deadlocks involving locking and waiting

Hello,

My static analysis tool reports two possible deadlocks in the vhost 
driver in Linux 5.16:

#BUG 1
vhost_net_set_backend()
   mutex_lock(&n->dev.mutex); --> Line 1511(Lock A)
   vhost_net_ubuf_put_wait_and_free()
     vhost_net_ubuf_put_and_wait()
     wait_event(ubufs->wait ...); --> Line 260 (Wait X)

vhost_net_ioctl()
   mutex_lock(&n->dev.mutex); --> Line 1734 (Lock A)
   vhost_net_flush()
     vhost_net_ubuf_put_and_wait()
       vhost_net_ubuf_put()
         wake_up(&ubufs->wait); --> Line 253 (Wake X)

When vhost_net_set_backend() is executed, "Wait X" is performed by 
holding "Lock A". If vhost_net_ioctl() is executed at this time, "Wake 
X" cannot be performed to wake up "Wait X" in vhost_net_set_backend(), 
because "Lock A" has been already hold by vhost_net_set_backend(), 
causing a possible deadlock.

#BUG2
vhost_net_set_backend()
   mutex_lock(&vq->mutex); --> Line 1522(Lock A)
   vhost_net_ubuf_put_wait_and_free()
     vhost_net_ubuf_put_and_wait()
     wait_event(ubufs->wait ...); --> Line 260 (Wait X)

handle_tx()
   mutex_lock_nested(&vq->mutex, ...); --> Line 966 (Lock A)
   handle_tx_zerocopy()
     vhost_net_ubuf_put()
       wake_up(&ubufs->wait); --> Line 253 (Wake X)

When vhost_net_set_backend() is executed, "Wait X" is performed by 
holding "Lock A". If handle_tx() is executed at this time, "Wake X" 
cannot be performed to wake up "Wait X" in vhost_net_set_backend(), 
because "Lock A" has been already hold by vhost_net_set_backend(), 
causing a possible deadlock.

I am not quite sure whether these possible problems are real and how to 
fix them if they are real.
Any feedback would be appreciated, thanks :)


Best wishes,
Jia-Ju Bai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ