iov_iter: fix the uaccess area in copy_compat_iovec_from_user
authorChristoph Hellwig <hch@lst.de>
Mon, 11 Jan 2021 17:19:26 +0000 (18:19 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 16 Jan 2021 03:51:42 +0000 (22:51 -0500)
sizeof needs to be called on the compat pointer, not the native one.

Fixes: 89cd35c58bc2 ("iov_iter: transparently handle compat iovecs in import_iovec")
Reported-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lib/iov_iter.c

index 1635111..a21e6a5 100644 (file)
@@ -1658,7 +1658,7 @@ static int copy_compat_iovec_from_user(struct iovec *iov,
                (const struct compat_iovec __user *)uvec;
        int ret = -EFAULT, i;
 
-       if (!user_access_begin(uvec, nr_segs * sizeof(*uvec)))
+       if (!user_access_begin(uiov, nr_segs * sizeof(*uiov)))
                return -EFAULT;
 
        for (i = 0; i < nr_segs; i++) {