Kaynağa Gözat

vhost: get/put_user -> __get/__put_user

We do access_ok checks on all ring values on an ioctl,
so we don't need to redo them on each access.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Michael S. Tsirkin 14 yıl önce
ebeveyn
işleme
8b7347aab6
1 değiştirilmiş dosya ile 8 ekleme ve 8 silme
  1. 8 8
      drivers/vhost/vhost.c

+ 8 - 8
drivers/vhost/vhost.c

@@ -1095,7 +1095,7 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
 
 
 	/* Check it isn't doing very strange things with descriptor numbers. */
 	/* Check it isn't doing very strange things with descriptor numbers. */
 	last_avail_idx = vq->last_avail_idx;
 	last_avail_idx = vq->last_avail_idx;
-	if (unlikely(get_user(vq->avail_idx, &vq->avail->idx))) {
+	if (unlikely(__get_user(vq->avail_idx, &vq->avail->idx))) {
 		vq_err(vq, "Failed to access avail idx at %p\n",
 		vq_err(vq, "Failed to access avail idx at %p\n",
 		       &vq->avail->idx);
 		       &vq->avail->idx);
 		return -EFAULT;
 		return -EFAULT;
@@ -1116,8 +1116,8 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
 
 
 	/* Grab the next descriptor number they're advertising, and increment
 	/* Grab the next descriptor number they're advertising, and increment
 	 * the index we've seen. */
 	 * the index we've seen. */
-	if (unlikely(get_user(head,
-			      &vq->avail->ring[last_avail_idx % vq->num]))) {
+	if (unlikely(__get_user(head,
+				&vq->avail->ring[last_avail_idx % vq->num]))) {
 		vq_err(vq, "Failed to read head: idx %d address %p\n",
 		vq_err(vq, "Failed to read head: idx %d address %p\n",
 		       last_avail_idx,
 		       last_avail_idx,
 		       &vq->avail->ring[last_avail_idx % vq->num]);
 		       &vq->avail->ring[last_avail_idx % vq->num]);
@@ -1216,17 +1216,17 @@ int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len)
 	/* The virtqueue contains a ring of used buffers.  Get a pointer to the
 	/* The virtqueue contains a ring of used buffers.  Get a pointer to the
 	 * next entry in that used ring. */
 	 * next entry in that used ring. */
 	used = &vq->used->ring[vq->last_used_idx % vq->num];
 	used = &vq->used->ring[vq->last_used_idx % vq->num];
-	if (put_user(head, &used->id)) {
+	if (__put_user(head, &used->id)) {
 		vq_err(vq, "Failed to write used id");
 		vq_err(vq, "Failed to write used id");
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
-	if (put_user(len, &used->len)) {
+	if (__put_user(len, &used->len)) {
 		vq_err(vq, "Failed to write used len");
 		vq_err(vq, "Failed to write used len");
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
 	/* Make sure buffer is written before we update index. */
 	/* Make sure buffer is written before we update index. */
 	smp_wmb();
 	smp_wmb();
-	if (put_user(vq->last_used_idx + 1, &vq->used->idx)) {
+	if (__put_user(vq->last_used_idx + 1, &vq->used->idx)) {
 		vq_err(vq, "Failed to increment used idx");
 		vq_err(vq, "Failed to increment used idx");
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
@@ -1319,7 +1319,7 @@ void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)
 	 * interrupts. */
 	 * interrupts. */
 	smp_mb();
 	smp_mb();
 
 
-	if (get_user(flags, &vq->avail->flags)) {
+	if (__get_user(flags, &vq->avail->flags)) {
 		vq_err(vq, "Failed to get flags");
 		vq_err(vq, "Failed to get flags");
 		return;
 		return;
 	}
 	}
@@ -1370,7 +1370,7 @@ bool vhost_enable_notify(struct vhost_virtqueue *vq)
 	/* They could have slipped one in as we were doing that: make
 	/* They could have slipped one in as we were doing that: make
 	 * sure it's written, then check again. */
 	 * sure it's written, then check again. */
 	smp_mb();
 	smp_mb();
-	r = get_user(avail_idx, &vq->avail->idx);
+	r = __get_user(avail_idx, &vq->avail->idx);
 	if (r) {
 	if (r) {
 		vq_err(vq, "Failed to check avail idx at %p: %d\n",
 		vq_err(vq, "Failed to check avail idx at %p: %d\n",
 		       &vq->avail->idx, r);
 		       &vq->avail->idx, r);