Skip to contentSkip to conversation

iov_iter: fix the uaccess area in copy_compat_iovec_from_user

PATCH Applied Christoph Hellwig 3 participants 3 messages Jan 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iov_iter: fix the uaccess area in copy_compat_iovec_from_user

sizeof needs to be called on the compat pointer, not the native one.

Fixes 89cd35c58bc2 ("iov_iter: transparently handle compat iovecs in import_iovec")
---
 lib/iov_iter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/iov_iter.c +1 -1
index 1635111c5bd2af..586215aa0f15ce 100644
@@ -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(uvec, nr_segs * sizeof(*uiov)))
 		return -EFAULT;
 
 	for (i = 0; i < nr_segs; i++) {
Signature · 1 line
2.29.2
#2 lore raw
In reply to Christoph Hellwig

From: Christoph Hellwig

Quoted 16 lines

Sent: 11 January 2021 17:19

sizeof needs to be called on the compat pointer, not the native one.

Fixes 89cd35c58bc2 ("iov_iter: transparently handle compat iovecs in import_iovec")
---
 lib/iov_iter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/iov_iter.c +0 -0
index 1635111c5bd2af..586215aa0f15ce 100644

lib/iov_iter.c static int copy_compat_iovec_from_user(struct iovec *iov, · line 1661

Quoted 5 lines
lib/iov_iter.c +1 -1
@@ -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(uvec, nr_segs * sizeof(*uiov)))

The first 'uvec' probably ought to be changed as well. Even though both variables have the same value.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)