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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210517093428.670-2-xieyongji@bytedance.com>
Date:   Mon, 17 May 2021 17:34:14 +0800
From:   Xie Yongji <xieyongji@...edance.com>
To:     mst@...hat.com, jasowang@...hat.com, stefanha@...hat.com
Cc:     amit@...nel.org, arei.gonglei@...wei.com, airlied@...ux.ie,
        kraxel@...hat.com, jean-philippe@...aro.org, ohad@...ery.com,
        bjorn.andersson@...aro.org, david@...hat.com, vgoyal@...hat.com,
        miklos@...redi.hu, lucho@...kov.net, asmadeus@...ewreck.org,
        virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org
Subject: [RFC PATCH 01/15] virtio_config: Add return value to virtio_device_ready()

We might get invalid status from untrusted device. Let's remove
BUG_ON and add return value to virtio_device_ready() to handle
this case gracefully.

Signed-off-by: Xie Yongji <xieyongji@...edance.com>
---
 include/linux/virtio_config.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 8519b3ae5d52..0e61cd89ac1d 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -225,12 +225,16 @@ int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs,
  * Note: vqs are enabled automatically after probe returns.
  */
 static inline
-void virtio_device_ready(struct virtio_device *dev)
+int virtio_device_ready(struct virtio_device *dev)
 {
 	unsigned status = dev->config->get_status(dev);
 
-	BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK);
+	if (status & VIRTIO_CONFIG_S_DRIVER_OK)
+		return -EINVAL;
+
 	dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK);
+
+	return 0;
 }
 
 static inline
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ