From 54f7a120c83c49ea9f64e4a07d1da115bb6a7516 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 23 Apr 2021 16:02:05 +0200 Subject: [PATCH] 5.11-stable patches added patches: vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch --- queue-5.11/series | 1 + ...current-access-to-vhost-device-iotlb.patch | 50 +++++++++++++++++++ queue-5.4/series | 0 3 files changed, 51 insertions(+) create mode 100644 queue-5.11/series create mode 100644 queue-5.11/vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch create mode 100644 queue-5.4/series diff --git a/queue-5.11/series b/queue-5.11/series new file mode 100644 index 00000000000..c1f11fa6a14 --- /dev/null +++ b/queue-5.11/series @@ -0,0 +1 @@ +vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch diff --git a/queue-5.11/vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch b/queue-5.11/vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch new file mode 100644 index 00000000000..c337f5b0791 --- /dev/null +++ b/queue-5.11/vhost-vdpa-protect-concurrent-access-to-vhost-device-iotlb.patch @@ -0,0 +1,50 @@ +From a9d064524fc3cf463b3bb14fa63de78aafb40dab Mon Sep 17 00:00:00 2001 +From: Xie Yongji +Date: Mon, 12 Apr 2021 17:55:12 +0800 +Subject: vhost-vdpa: protect concurrent access to vhost device iotlb + +From: Xie Yongji + +commit a9d064524fc3cf463b3bb14fa63de78aafb40dab upstream. + +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. + +Fixes: 4c8cf318("vhost: introduce vDPA-based backend") +Cc: stable@vger.kernel.org +Signed-off-by: Xie Yongji +Acked-by: Jason Wang +Reviewed-by: Stefano Garzarella +Link: https://lore.kernel.org/r/20210412095512.178-1-xieyongji@bytedance.com +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/vhost/vdpa.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/vhost/vdpa.c ++++ b/drivers/vhost/vdpa.c +@@ -745,9 +745,11 @@ static int vhost_vdpa_process_iotlb_msg( + const struct vdpa_config_ops *ops = vdpa->config; + int r = 0; + ++ mutex_lock(&dev->mutex); ++ + r = vhost_dev_check_owner(dev); + if (r) +- return r; ++ goto unlock; + + switch (msg->type) { + case VHOST_IOTLB_UPDATE: +@@ -768,6 +770,8 @@ static int vhost_vdpa_process_iotlb_msg( + r = -EINVAL; + break; + } ++unlock: ++ mutex_unlock(&dev->mutex); + + return r; + } diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..e69de29bb2d -- 2.47.3