Don't feed anything but regular iovec's to blk_rq_map_user_iov
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 7 Dec 2016 00:18:14 +0000 (16:18 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 7 Dec 2016 16:23:35 +0000 (08:23 -0800)
In theory we could map other things, but there's a reason that function
is called "user_iov".  Using anything else (like splice can do) just
confuses it.

Reported-and-tested-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
block/blk-map.c

index b8657fa8dc9af7b2f5fe7958693df063cc4c9019..27fd8d92892d47e3478d9bcf3e1294a8eb28da89 100644 (file)
@@ -118,6 +118,9 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
        struct iov_iter i;
        int ret;
 
+       if (!iter_is_iovec(iter))
+               goto fail;
+
        if (map_data)
                copy = true;
        else if (iov_iter_alignment(iter) & align)
@@ -140,6 +143,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
 
 unmap_rq:
        __blk_rq_unmap_user(bio);
+fail:
        rq->bio = NULL;
        return -EINVAL;
 }