aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/vhost.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vhost/vhost.c')
-rw-r--r--drivers/vhost/vhost.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ed71b5347a76..cb807d0ea498 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -713,9 +713,13 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
713 r = -EFAULT; 713 r = -EFAULT;
714 break; 714 break;
715 } 715 }
716 if ((a.avail_user_addr & (sizeof *vq->avail->ring - 1)) || 716
717 (a.used_user_addr & (sizeof *vq->used->ring - 1)) || 717 /* Make sure it's safe to cast pointers to vring types. */
718 (a.log_guest_addr & (sizeof *vq->used->ring - 1))) { 718 BUILD_BUG_ON(__alignof__ *vq->avail > VRING_AVAIL_ALIGN_SIZE);
719 BUILD_BUG_ON(__alignof__ *vq->used > VRING_USED_ALIGN_SIZE);
720 if ((a.avail_user_addr & (VRING_AVAIL_ALIGN_SIZE - 1)) ||
721 (a.used_user_addr & (VRING_USED_ALIGN_SIZE - 1)) ||
722 (a.log_guest_addr & (sizeof(u64) - 1))) {
719 r = -EINVAL; 723 r = -EINVAL;
720 break; 724 break;
721 } 725 }