lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1652241268-46732-3-git-send-email-jdamato@fastly.com>
Date:   Tue, 10 May 2022 20:54:23 -0700
From:   Joe Damato <jdamato@...tly.com>
To:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        linux-kernel@...r.kernel.org, x86@...nel.org,
        Alexander Viro <viro@...iv.linux.org.uk>
Cc:     Joe Damato <jdamato@...tly.com>
Subject: [RFC,net-next 2/6] iov_iter: Allow custom copyin function

When calling copy_page_from_iter_iovec, allow callers to specify the copy
function they'd like to use.

The only caller is updated to pass raw_copy_from_user.

Signed-off-by: Joe Damato <jdamato@...tly.com>
---
 lib/iov_iter.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 6dd5330..ef22ec1 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -253,7 +253,9 @@ static size_t copy_page_to_iter_iovec(struct page *page, size_t offset, size_t b
 }
 
 static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t bytes,
-			 struct iov_iter *i)
+			 struct iov_iter *i,
+			 unsigned long (*_copyin)(void *to, const void __user *from,
+						 unsigned long n))
 {
 	size_t skip, copy, left, wanted;
 	const struct iovec *iov;
@@ -278,7 +280,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
 		to = kaddr + offset;
 
 		/* first chunk, usually the only one */
-		left = copyin(to, buf, copy);
+		left = _copyin(to, buf, copy);
 		copy -= left;
 		skip += copy;
 		to += copy;
@@ -288,7 +290,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
 			iov++;
 			buf = iov->iov_base;
 			copy = min(bytes, iov->iov_len);
-			left = copyin(to, buf, copy);
+			left = _copyin(to, buf, copy);
 			copy -= left;
 			skip = copy;
 			to += copy;
@@ -307,7 +309,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
 
 	kaddr = kmap(page);
 	to = kaddr + offset;
-	left = copyin(to, buf, copy);
+	left = _copyin(to, buf, copy);
 	copy -= left;
 	skip += copy;
 	to += copy;
@@ -316,7 +318,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
 		iov++;
 		buf = iov->iov_base;
 		copy = min(bytes, iov->iov_len);
-		left = copyin(to, buf, copy);
+		left = _copyin(to, buf, copy);
 		copy -= left;
 		skip = copy;
 		to += copy;
@@ -899,7 +901,7 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes,
 	if (unlikely(!page_copy_sane(page, offset, bytes)))
 		return 0;
 	if (likely(iter_is_iovec(i)))
-		return copy_page_from_iter_iovec(page, offset, bytes, i);
+		return copy_page_from_iter_iovec(page, offset, bytes, i, raw_copy_from_user);
 	if (iov_iter_is_bvec(i) || iov_iter_is_kvec(i) || iov_iter_is_xarray(i)) {
 		void *kaddr = kmap_local_page(page);
 		size_t wanted = _copy_from_iter(kaddr + offset, bytes, i);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ