Re: [PATCH v5 04/13] vdpa: Read device configuration only if FEATURES_OK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 12/21/2021 9:19 AM, Eli Cohen wrote:
Avoid reading device configuration during feature negotiation. Read
device status and verify that VIRTIO_CONFIG_S_FEATURES_OK is set.

Otherwise, return -EAGAIN.

Signed-off-by: Eli Cohen <elic@xxxxxxxxxx>
---
  drivers/vdpa/vdpa.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 5134c83c4a22..3285cebd89c0 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -838,8 +838,18 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,
  {
  	u32 device_id;
  	void *hdr;
+	u8 status;
  	int err;
+ mutex_lock(&vdev->cf_mutex);
+	status = vdev->config->get_status(vdev);
Atomicity and data consistency not guaranteed against vdpa_get_config and get_features in vdpa_dev_net_config_fill(). Need to use coarse locking.

-Siwei
+	if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
+		NL_SET_ERR_MSG_MOD(extack, "Features negotiation not completed");
+		mutex_unlock(&vdev->cf_mutex);
+		return -EAGAIN;
+	}
+	mutex_unlock(&vdev->cf_mutex);
+
  	hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags,
  			  VDPA_CMD_DEV_CONFIG_GET);
  	if (!hdr)

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux