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: <160596815823.154728.8595962159705739709.stgit@warthog.procyon.org.uk>
Date:   Sat, 21 Nov 2020 14:15:58 +0000
From:   David Howells <dhowells@...hat.com>
To:     Pavel Begunkov <asml.silence@...il.com>,
        Matthew Wilcox <willy@...radead.org>,
        Jens Axboe <axboe@...nel.dk>,
        Alexander Viro <viro@...iv.linux.org.uk>
Cc:     dhowells@...hat.com,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        linux-fsdevel@...r.kernel.org, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 20/29] iov_iter: Split iov_iter_gap_alignment()

Split iov_iter_gap_alignment() by type.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 lib/iov_iter.c |   50 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index d2a66e951995..5744ddec854f 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1542,27 +1542,45 @@ static unsigned long no_alignment(const struct iov_iter *i)
 	return 0;
 }
 
-static unsigned long xxx_gap_alignment(const struct iov_iter *i)
+static unsigned long iovec_gap_alignment(const struct iov_iter *i)
 {
 	unsigned long res = 0;
 	size_t size = i->count;
 
-	if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
-		WARN_ON(1);
-		return ~0U;
-	}
-
-	iterate_all_kinds(i, size, v,
+	iterate_over_iovec(i, size, v,
 		(res |= (!res ? 0 : (unsigned long)v.iov_base) |
-			(size != v.iov_len ? size : 0), 0),
+			(size != v.iov_len ? size : 0), 0));
+	return res;
+}
+
+static unsigned long bvec_gap_alignment(const struct iov_iter *i)
+{
+	unsigned long res = 0;
+	size_t size = i->count;
+
+	iterate_over_bvec(i, size, v,
 		(res |= (!res ? 0 : (unsigned long)v.bv_offset) |
-			(size != v.bv_len ? size : 0)),
+			(size != v.bv_len ? size : 0)));
+	return res;
+}
+
+static unsigned long kvec_gap_alignment(const struct iov_iter *i)
+{
+	unsigned long res = 0;
+	size_t size = i->count;
+
+	iterate_over_kvec(i, size, v,
 		(res |= (!res ? 0 : (unsigned long)v.iov_base) |
-			(size != v.iov_len ? size : 0))
-		);
+			(size != v.iov_len ? size : 0)));
 	return res;
 }
 
+static unsigned long no_gap_alignment(const struct iov_iter *i)
+{
+	WARN_ON(1);
+	return ~0U;
+}
+
 static inline ssize_t __pipe_get_pages(struct iov_iter *i,
 				size_t maxsize,
 				struct page **pages,
@@ -2160,7 +2178,7 @@ static const struct iov_iter_ops iovec_iter_ops = {
 
 	.zero				= iovec_zero,
 	.alignment			= iovec_alignment,
-	.gap_alignment			= xxx_gap_alignment,
+	.gap_alignment			= iovec_gap_alignment,
 	.get_pages			= xxx_get_pages,
 	.get_pages_alloc		= xxx_get_pages_alloc,
 	.npages				= xxx_npages,
@@ -2194,7 +2212,7 @@ static const struct iov_iter_ops kvec_iter_ops = {
 
 	.zero				= kvec_zero,
 	.alignment			= kvec_alignment,
-	.gap_alignment			= xxx_gap_alignment,
+	.gap_alignment			= kvec_gap_alignment,
 	.get_pages			= xxx_get_pages,
 	.get_pages_alloc		= xxx_get_pages_alloc,
 	.npages				= xxx_npages,
@@ -2228,7 +2246,7 @@ static const struct iov_iter_ops bvec_iter_ops = {
 
 	.zero				= bvec_zero,
 	.alignment			= bvec_alignment,
-	.gap_alignment			= xxx_gap_alignment,
+	.gap_alignment			= bvec_gap_alignment,
 	.get_pages			= xxx_get_pages,
 	.get_pages_alloc		= xxx_get_pages_alloc,
 	.npages				= xxx_npages,
@@ -2262,7 +2280,7 @@ static const struct iov_iter_ops pipe_iter_ops = {
 
 	.zero				= pipe_zero,
 	.alignment			= pipe_alignment,
-	.gap_alignment			= xxx_gap_alignment,
+	.gap_alignment			= no_gap_alignment,
 	.get_pages			= xxx_get_pages,
 	.get_pages_alloc		= xxx_get_pages_alloc,
 	.npages				= xxx_npages,
@@ -2296,7 +2314,7 @@ static const struct iov_iter_ops discard_iter_ops = {
 
 	.zero				= discard_zero,
 	.alignment			= no_alignment,
-	.gap_alignment			= xxx_gap_alignment,
+	.gap_alignment			= no_gap_alignment,
 	.get_pages			= xxx_get_pages,
 	.get_pages_alloc		= xxx_get_pages_alloc,
 	.npages				= xxx_npages,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ