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>] [thread-next>] [day] [month] [year] [list]
Date:   Sun,  6 Jun 2021 18:59:09 +0530
From:   Gautam Dawar <gdawar.xilinx@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     martinh@...inx.com, hanand@...inx.com, gdawar@...inx.com,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>, kvm@...r.kernel.org,
        virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] vhost-vdpa: log warning message if vhost_vdpa_remove gets blocked

From: Gautam Dawar <gdawar@...inx.com>

If some module invokes vdpa_device_unregister (usually in the module
unload function) when the userspace app (eg. QEMU) which had opened
the vhost-vdpa character device is still running, vhost_vdpa_remove()
function will block indefinitely in call to wait_for_completion().

This causes the vdpa_device_unregister caller to hang and with a
usual side-effect of rmmod command not returning when this call
is in the module_exit function.

This patch converts the wait_for_completion call to its timeout based
counterpart (wait_for_completion_timeout) and also adds a warning
message to alert the user/administrator about this hang situation.

To eventually fix this problem, a mechanism will be required to let
vhost-vdpa module inform the userspace of this situation and
userspace will close the descriptor of vhost-vdpa char device.
This will enable vhost-vdpa to continue with graceful clean-up.

Signed-off-by: Gautam Dawar <gdawar@...inx.com>
---
 drivers/vhost/vdpa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index bfa4c6ef554e..572b64d09b06 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1091,7 +1091,11 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa)
 		opened = atomic_cmpxchg(&v->opened, 0, 1);
 		if (!opened)
 			break;
-		wait_for_completion(&v->completion);
+		wait_for_completion_timeout(&v->completion,
+					    msecs_to_jiffies(1000));
+		dev_warn_ratelimited(&v->dev,
+				     "%s waiting for /dev/%s to be closed\n",
+				     __func__, dev_name(&v->dev));
 	} while (1);
 
 	put_device(&v->dev);
-- 
2.30.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ