]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
sg_io(): use import_iovec()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 22 Mar 2015 00:02:55 +0000 (20:02 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Apr 2015 02:27:13 +0000 (22:27 -0400)
... and don't skip access_ok() validation.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
block/scsi_ioctl.c

index e1f71c3961934b9ed9adbf01247d196b05801750..55b6f15dac900af77a5ad7038cd98f3133d816a8 100644 (file)
@@ -335,16 +335,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
                struct iov_iter i;
                struct iovec *iov = NULL;
 
-               ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count,
-                                           0, NULL, &iov);
-               if (ret < 0) {
-                       kfree(iov);
+               ret = import_iovec(rq_data_dir(rq),
+                                  hdr->dxferp, hdr->iovec_count,
+                                  0, &iov, &i);
+               if (ret < 0)
                        goto out_free_cdb;
-               }
 
                /* SG_IO howto says that the shorter of the two wins */
-               iov_iter_init(&i, rq_data_dir(rq), iov, hdr->iovec_count,
-                             min_t(unsigned, ret, hdr->dxfer_len));
+               iov_iter_truncate(&i, hdr->dxfer_len);
 
                ret = blk_rq_map_user_iov(q, rq, NULL, &i, GFP_KERNEL);
                kfree(iov);