All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] generic/286: fix integer underflow on block sizes != 4096
@ 2021-05-22 18:48 Jakob Unterwurzacher
  2021-05-23  9:05 ` Eryu Guan
  0 siblings, 1 reply; 6+ messages in thread
From: Jakob Unterwurzacher @ 2021-05-22 18:48 UTC (permalink / raw)
  To: fstests; +Cc: Jakob Unterwurzacher

The read loop always requested 4096 bytes, which only works
when the total read length is a multiple of 4096 bytes.

This is not neccessarily true, and when it's not, len wraps
around to UINT64_MAX and you get a lot of these:

	ERROR: [error:38] reached EOF:Success

This was caught when running xfstests against gocryptfs,
an encrypted overlay file system.

On ext4, the test still passes after this change.

Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
---
 src/seek_copy_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/seek_copy_test.c b/src/seek_copy_test.c
index 0c2c6a3d..28c021e2 100644
--- a/src/seek_copy_test.c
+++ b/src/seek_copy_test.c
@@ -98,7 +98,7 @@ do_extent_copy(int src_fd, int dest_fd, off_t data_off, off_t hole_off)
 	}
 
 	while (len > 0) {
-		ssize_t nr_read = read(src_fd, buf, BUF_SIZE);
+		ssize_t nr_read = read(src_fd, buf, MIN(len, BUF_SIZE));
 		if (nr_read < 0) {
 			if (errno == EINTR)
 				continue;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-26  8:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-22 18:48 [PATCH] generic/286: fix integer underflow on block sizes != 4096 Jakob Unterwurzacher
2021-05-23  9:05 ` Eryu Guan
2021-05-25 17:34   ` Jakob Unterwurzacher
2021-05-26  3:20     ` Eryu Guan
2021-05-26  3:41       ` Darrick J. Wong
2021-05-26  8:02         ` Jakob Unterwurzacher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.