diff mbox series

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

Message ID 04fbf8632f83496d819f27bb353dbf39@AcuMS.aculab.com
State Not Applicable
Delegated to: David Miller
Headers show
Series Optimisation to the 'iovec' copying code. | expand

Commit Message

David Laight Jan. 24, 2020, 3:46 p.m. UTC
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().

Signed-off-by: David Laight <david.laight@aculab.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/read_write.c b/fs/read_write.c
index 441d9ca..0241d68 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -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;
 	}