summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0001-syscalls-copy_file_range02-Expect-EFBIG-in-subcase-m.patch
blob: 09b6f5487451d7d2ea8372f545d1228b50f8ba7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 99687ab002f9f750f6f18fa1d70a91f0aa4f8ba2 Mon Sep 17 00:00:00 2001
From: He Zhe <zhe.he@windriver.com>
Date: Thu, 18 Jun 2020 17:18:27 +0800
Subject: [PATCH] syscalls/copy_file_range02: Expect EFBIG in subcase max
 length on 32-bit architectures

For syscall
ssize_t copy_file_range(int fd_in, loff_t *off_in,
                               int fd_out, loff_t *off_out,
                               size_t len, unsigned int flags);
off_out is loff_t* that is long long, 64 bits on 32-bit architectures,
while len is size_t that unsigned int, 32 bits on 32-bit architectures.

In subcase "max length", simplified as below,

dst = tst_max_lfs_filesize();
TEST(sys_copy_file_range(fd_src, 0, *tc->copy_to_fd, &dst, tc->len, tc->flags));

where dst is 4K*4G and len is 4G, so (4K+1)*4G is always smaller than 4G*4G,
it can never match the following kernel condition on 32-bit architectures.

if (pos_in + count < pos_in || pos_out + count < pos_out)
	return -EOVERFLOW;

And thus we would get error like
copy_file_range02.c:139: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EFBIG (27)

Also correct a typo.

Upstream-Status: Backport [http://lists.linux.it/pipermail/ltp/2020-June/017716.html]

Signed-off-by: He Zhe <zhe.he@windriver.com>
Acked-by: Li Wang <liwang@redhat.com>
---
 .../kernel/syscalls/copy_file_range/copy_file_range02.c     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
index fa679c4d3..bc27fbe57 100644
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
@@ -78,7 +78,11 @@ static struct tcase {
 	{&fd_chrdev,	0,	EINVAL,		CONTSIZE,	"char device",	0},
 	{&fd_fifo,	0,	EINVAL,		CONTSIZE,	"fifo", 	0},
 	{&fd_pipe[0],	0,	EINVAL,		CONTSIZE,	"pipe", 	0},
-	{&fd_copy,	0,	EOVERFLOW,	ULLONG_MAX,	"max length lenght", 	1},
+#ifdef TST_ABI64
+	{&fd_copy,	0,	EOVERFLOW,	ULLONG_MAX,	"max length", 	1},
+#else
+	{&fd_copy,	0,	EFBIG,		ULLONG_MAX,	"max length", 	1},
+#endif
 	{&fd_copy,	0,	EFBIG,		MIN_OFF,	"max file size", 	1},
 };
 
-- 
2.17.1