Skip to contentSkip to conversation

Use _copy_from_user() to read SG iovec array.

PATCH New David Laight 1 participant 1 message Jan 24, 2020

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

PATCH 2/3 Use _copy_from_user() to read SG iovec array.

The code has either just validated that the size fits in a caller supplied fixed size buffer or has used kmalloc() to allocate a buffer. So avoid the non-trivial cost of the HARDENED_USERCOPY checks by calling _copy_from_user() instead of copy_from_user().

---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/read_write.c +1 -1
index 441d9ca..0241d68 100644
@@ -795,7 +795,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
 			goto out;
 		}
 	}
-	if (copy_from_user(iov, uvector, nr_segs*sizeof(*uvector))) {
+	if (_copy_from_user(iov, uvector, nr_segs*sizeof(*uvector))) {
 		ret = -EFAULT;
 		goto out;
 	}
Signature · 5 lines
1.8.1.2

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