Skip to content

Commit

Permalink
vdpa: Protect vdpa reset with cf_mutex
Browse files Browse the repository at this point in the history
Call reset using the wrapper function vdpa_reset() to make sure the
operation is serialized with cf_mutex.

This comes to protect from the following possible scenario:

vhost_vdpa_set_status() could call the reset op. Since the call is not
protected by cf_mutex, a netlink thread calling vdpa_dev_config_fill
could get passed the VIRTIO_CONFIG_S_FEATURES_OK check in
vdpa_dev_config_fill() and end up reporting wrong features.

Fixes: 5f6e859 ("vdpa: Read device configuration only if FEATURES_OK")
Signed-off-by: Eli Cohen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Si-Wei Liu<[email protected]>
Acked-by: Jason Wang <[email protected]>
  • Loading branch information
elic307i authored and mstsirkin committed Jan 14, 2022
1 parent f6d955d commit 680ab9d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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
Expand Down

0 comments on commit 680ab9d

Please sign in to comment.