History

vhost-vdpa: protect concurrent access to vhost device iotlb

Protect vhost device iotlb by vhost_dev->mutex. Otherwise, it might cause corruption of the list and interval tree in struct vhost_iotlb if userspace sends the VHOST_IOTLB_MSG_V2 message concurrently.

Xie Yongji committed 5 years ago

Commit a9d06451 parent bc04d931 file · +5 −1Browse files

Unified · Split

drivers/vhost/vdpa.c+5−1
@@ -745,9 +745,11 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, · 744 unmodified lines
745745 const struct vdpa_config_ops *ops = vdpa->config;
746746 int r = 0;
747747
748+ mutex_lock(&dev->mutex);
749+
748750 r = vhost_dev_check_owner(dev);
749751 if (r)
750− return r;
752+ goto unlock;
751753
752754 switch (msg->type) {
753755 case VHOST_IOTLB_UPDATE:
@@ -768,6 +770,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, · 14 unmodified lines
768770 r = -EINVAL;
769771 break;
770772 }
773+unlock:
774+ mutex_unlock(&dev->mutex);
771775
772776 return r;
773777 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t