vdpa: Protect vdpa reset with cf_mutex
Si-Wei Liu
Reviewed-byQuoted 13 lines · Eli Cohen
Call reset using the wrapper function
vdpa_reset()to make sure the operation is serialized withcf_mutex.Signed-off-by Eli Cohen <[email protected]>--- drivers/vhost/vdpa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/vhost/vdpa.c +0
-0
drivers/vhost/vdpa.c static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp) · line 158
Quoted 4 lines
drivers/vhost/vdpa.c +0
-1@@ -155,7 +155,6 @@ static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)static long vhost_vdpa_set_status (struct vhost_vdpa *v,u8 __user *statusp) {struct vdpa_device *vdpa = v->vdpa; -const struct vdpa_config_ops *ops = vdpa->config;
It is okay to remove this line from the patch, but a follow-up patch to remove the locking for get_status would need to reintroduce the same line. If possible please try post these two together in a same series.
drivers/vhost/vdpa.c static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp) · line 182
Quoted 12 lines
drivers/vhost/vdpa.c +1
-1u8 status, status_old;int ret, nvqs = v->nvqs;u16 i;@@ -177,7 +176,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)vhost_vdpa_unsetup_vq_irq (v, i);if (status ==0 ) { - ret = ops->reset (vdpa); + ret =vdpa_reset (vdpa);if (ret)return ret; }else
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 4 lines · Eli Cohen
Call reset using the wrapper function
vdpa_reset()to make sure the operation is serialized withcf_mutex.Signed-off-by Eli Cohen <[email protected]>
The motivation is vague here, this does not really explain. Which operations are we trying to serialize? Multiple reset requests from userspace?
Is anything broken right now without this patch?
Quoted 27 lines
--- drivers/vhost/vdpa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/vhost/vdpa.c +1
-2@@ -155,7 +155,6 @@ static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)static long vhost_vdpa_set_status (struct vhost_vdpa *v,u8 __user *statusp) {struct vdpa_device *vdpa = v->vdpa; -const struct vdpa_config_ops *ops = vdpa->config;u8 status, status_old;int ret, nvqs = v->nvqs;u16 i;@@ -177,7 +176,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)vhost_vdpa_unsetup_vq_irq (v, i);if (status ==0 ) { - ret = ops->reset (vdpa); + ret =vdpa_reset (vdpa);if (ret)return ret; }else Signature · 1 line
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 7 lines · Eli Cohen
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen
Call reset using the wrapper function
vdpa_reset()to make sure the operation is serialized withcf_mutex.Signed-off-by Eli Cohen <[email protected]>
Quoted 8 lines
Quoted 4 lines
The motivation is vague here, this does not really explain. Which operations are we trying to serialize? Multiple reset requests from userspace?
Is anything broken right now without this patch?
vdpa_resetwill reset the features which can be read or even be set through devlink (seevdpa_get_config_unlocked()). So this lock ensures serialization of the operations to ensure consitent value is read.
My point is that this is the kind of thing that needs to go into commit log. A good log for a bugfix looks like this:
if XYZ triggers a vdpa reset while ABC is reading the features through devlink, with the result that EFG. Similarly for write which can lead to HIJ.
Fix this by calling reset using the wrapper function vdpa_reset() to make sure the operation is serialized with cf_mutex.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
--- drivers/vhost/vdpa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/vhost/vdpa.c +0
-1@@ -155,7 +155,6 @@ static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)static long vhost_vdpa_set_status (struct vhost_vdpa *v,u8 __user *statusp) {struct vdpa_device *vdpa = v->vdpa; -const struct vdpa_config_ops *ops = vdpa->config;u8 status, status_old;int ret, nvqs = v->nvqs;u16 i;@@ -177,7 +176,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)vhost_vdpa_unsetup_vq_irq (v, i);
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/vhost/vdpa.c +1
-1if (status ==0 ) { - ret = ops->reset (vdpa); + ret =vdpa_reset (vdpa);if (ret)return ret; }else Signature · 1 line
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization