diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-extended/ltp/ltp/0001-syscalls-fcntl-make-OFD-command-use-fcntl64-syscall-.patch | 184 | ||||
-rw-r--r-- | meta/recipes-extended/ltp/ltp_20180515.bb | 1 |
2 files changed, 185 insertions, 0 deletions
diff --git a/meta/recipes-extended/ltp/ltp/0001-syscalls-fcntl-make-OFD-command-use-fcntl64-syscall-.patch b/meta/recipes-extended/ltp/ltp/0001-syscalls-fcntl-make-OFD-command-use-fcntl64-syscall-.patch new file mode 100644 index 0000000000..2755596d03 --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0001-syscalls-fcntl-make-OFD-command-use-fcntl64-syscall-.patch | |||
@@ -0,0 +1,184 @@ | |||
1 | From 8de03ea1200480b922d5ba05b69dc94db60496f5 Mon Sep 17 00:00:00 2001 | ||
2 | From: "Hongzhi.Song" <hongzhi.song@windriver.com> | ||
3 | Date: Sat, 15 Sep 2018 22:39:32 -0400 | ||
4 | Subject: [PATCH] syscalls/fcntl: make OFD command use fcntl64() syscall on | ||
5 | 32-bit | ||
6 | |||
7 | To cope with glibc commit: | ||
8 | 06ab719d30b0 ("Fix Linux fcntl OFD locks for non-LFS architectures | ||
9 | (BZ#20251)") | ||
10 | |||
11 | WIP: Still need to test this with new glibc. | ||
12 | Test with old glibc look OK so far. | ||
13 | |||
14 | Signed-off-by: Jan Stancek <jstancek@redhat.com> | ||
15 | |||
16 | Upstream-Status: Backport | ||
17 | Backported from upstream maillist | ||
18 | https://lists.linux.it/pipermail/ltp/2018-September/009370.html | ||
19 | |||
20 | Signed-off-by: Hongzhi Song <hongzhi.song@windriver.com> | ||
21 | --- | ||
22 | testcases/kernel/syscalls/fcntl/fcntl34.c | 12 +++++++--- | ||
23 | testcases/kernel/syscalls/fcntl/fcntl36.c | 23 +++++++++++++----- | ||
24 | testcases/kernel/syscalls/fcntl/fcntl_common.h | 32 ++++++++++++++++++++++++++ | ||
25 | 3 files changed, 58 insertions(+), 9 deletions(-) | ||
26 | create mode 100644 testcases/kernel/syscalls/fcntl/fcntl_common.h | ||
27 | |||
28 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl34.c b/testcases/kernel/syscalls/fcntl/fcntl34.c | ||
29 | index aa29cf9..109f834 100644 | ||
30 | --- a/testcases/kernel/syscalls/fcntl/fcntl34.c | ||
31 | +++ b/testcases/kernel/syscalls/fcntl/fcntl34.c | ||
32 | @@ -28,6 +28,7 @@ | ||
33 | #include "lapi/fcntl.h" | ||
34 | #include "tst_safe_pthread.h" | ||
35 | #include "tst_test.h" | ||
36 | +#include "fcntl_common.h" | ||
37 | |||
38 | static int thread_cnt; | ||
39 | static const int max_thread_cnt = 32; | ||
40 | @@ -68,7 +69,12 @@ void *thread_fn_01(void *arg) | ||
41 | |||
42 | memset(buf, (intptr_t)arg, write_size); | ||
43 | |||
44 | - struct flock64 lck = { | ||
45 | + /* see explanation in fcntl_common.h */ | ||
46 | + #ifdef USE_STRUCT_FLOCK | ||
47 | + struct flock lck = { | ||
48 | + #else | ||
49 | + struct flock64 lck = { | ||
50 | + #endif | ||
51 | .l_whence = SEEK_SET, | ||
52 | .l_start = 0, | ||
53 | .l_len = 1, | ||
54 | @@ -76,13 +82,13 @@ void *thread_fn_01(void *arg) | ||
55 | |||
56 | for (i = 0; i < writes_num; ++i) { | ||
57 | lck.l_type = F_WRLCK; | ||
58 | - SAFE_FCNTL(fd, F_OFD_SETLKW, &lck); | ||
59 | + my_fcntl(fd, F_OFD_SETLKW, &lck); | ||
60 | |||
61 | SAFE_LSEEK(fd, 0, SEEK_END); | ||
62 | SAFE_WRITE(1, fd, buf, write_size); | ||
63 | |||
64 | lck.l_type = F_UNLCK; | ||
65 | - SAFE_FCNTL(fd, F_OFD_SETLKW, &lck); | ||
66 | + my_fcntl(fd, F_OFD_SETLKW, &lck); | ||
67 | |||
68 | sched_yield(); | ||
69 | } | ||
70 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl36.c b/testcases/kernel/syscalls/fcntl/fcntl36.c | ||
71 | index 3246d13..f263b6b 100644 | ||
72 | --- a/testcases/kernel/syscalls/fcntl/fcntl36.c | ||
73 | +++ b/testcases/kernel/syscalls/fcntl/fcntl36.c | ||
74 | @@ -57,6 +57,7 @@ | ||
75 | #include "lapi/fcntl.h" | ||
76 | #include "tst_safe_pthread.h" | ||
77 | #include "tst_test.h" | ||
78 | +#include "fcntl_common.h" | ||
79 | |||
80 | static int thread_cnt; | ||
81 | static int fail_flag = 0; | ||
82 | @@ -87,7 +88,12 @@ static void *fn_ofd_w(void *arg) | ||
83 | int fd = SAFE_OPEN(fname, O_RDWR); | ||
84 | long wt = pa->cnt; | ||
85 | |||
86 | - struct flock64 lck = { | ||
87 | + /* see explanation in fcntl_common.h */ | ||
88 | + #ifdef USE_STRUCT_FLOCK | ||
89 | + struct flock lck = { | ||
90 | + #else | ||
91 | + struct flock64 lck = { | ||
92 | + #endif | ||
93 | .l_whence = SEEK_SET, | ||
94 | .l_start = pa->offset, | ||
95 | .l_len = pa->length, | ||
96 | @@ -99,13 +105,13 @@ static void *fn_ofd_w(void *arg) | ||
97 | memset(buf, wt, pa->length); | ||
98 | |||
99 | lck.l_type = F_WRLCK; | ||
100 | - SAFE_FCNTL(fd, F_OFD_SETLKW, &lck); | ||
101 | + my_fcntl(fd, F_OFD_SETLKW, &lck); | ||
102 | |||
103 | SAFE_LSEEK(fd, pa->offset, SEEK_SET); | ||
104 | SAFE_WRITE(1, fd, buf, pa->length); | ||
105 | |||
106 | lck.l_type = F_UNLCK; | ||
107 | - SAFE_FCNTL(fd, F_OFD_SETLKW, &lck); | ||
108 | + my_fcntl(fd, F_OFD_SETLKW, &lck); | ||
109 | |||
110 | wt++; | ||
111 | if (wt >= 255) | ||
112 | @@ -166,7 +172,12 @@ static void *fn_ofd_r(void *arg) | ||
113 | int i; | ||
114 | int fd = SAFE_OPEN(fname, O_RDWR); | ||
115 | |||
116 | - struct flock64 lck = { | ||
117 | + /* see explanation in fcntl_common.h */ | ||
118 | + #ifdef USE_STRUCT_FLOCK | ||
119 | + struct flock lck = { | ||
120 | + #else | ||
121 | + struct flock64 lck = { | ||
122 | + #endif | ||
123 | .l_whence = SEEK_SET, | ||
124 | .l_start = pa->offset, | ||
125 | .l_len = pa->length, | ||
126 | @@ -178,7 +189,7 @@ static void *fn_ofd_r(void *arg) | ||
127 | memset(buf, 0, pa->length); | ||
128 | |||
129 | lck.l_type = F_RDLCK; | ||
130 | - SAFE_FCNTL(fd, F_OFD_SETLKW, &lck); | ||
131 | + my_fcntl(fd, F_OFD_SETLKW, &lck); | ||
132 | |||
133 | /* rlock acquired */ | ||
134 | SAFE_LSEEK(fd, pa->offset, SEEK_SET); | ||
135 | @@ -209,7 +220,7 @@ static void *fn_ofd_r(void *arg) | ||
136 | } | ||
137 | |||
138 | lck.l_type = F_UNLCK; | ||
139 | - SAFE_FCNTL(fd, F_OFD_SETLK, &lck); | ||
140 | + my_fcntl(fd, F_OFD_SETLK, &lck); | ||
141 | |||
142 | sched_yield(); | ||
143 | } | ||
144 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl_common.h b/testcases/kernel/syscalls/fcntl/fcntl_common.h | ||
145 | new file mode 100644 | ||
146 | index 0000000..3fe399b | ||
147 | --- /dev/null | ||
148 | +++ b/testcases/kernel/syscalls/fcntl/fcntl_common.h | ||
149 | @@ -0,0 +1,32 @@ | ||
150 | +#include "lapi/syscalls.h" | ||
151 | + | ||
152 | +/* | ||
153 | + * glibc commit: | ||
154 | + * 06ab719d30b0 ("Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)") | ||
155 | + * changed behavior of arg parameter for OFD commands. It is no | ||
156 | + * longer passing arg directly to syscall, but expects it to be | ||
157 | + * 'struct flock'. | ||
158 | + * | ||
159 | + * On 64-bit or _FILE_OFFSET_BITS == 64 we can use fcntl() and | ||
160 | + * struct flock with any glibc version. struct flock and flock64 | ||
161 | + * should be identical. | ||
162 | + * | ||
163 | + * On 32-bit, older glibc would pass arg directly, recent one treats | ||
164 | + * it as 'struct flock' and converts it to 'struct flock64'. | ||
165 | + * So, for 32-bit we use fcntl64 syscall directly with struct flock64. | ||
166 | + */ | ||
167 | +#if __WORDSIZE == 64 || _FILE_OFFSET_BITS == 64 | ||
168 | +#define USE_STRUCT_FLOCK | ||
169 | +static int my_fcntl(int fd, int cmd, void *lck) | ||
170 | +{ | ||
171 | + return SAFE_FCNTL(fd, cmd, lck); | ||
172 | +} | ||
173 | +#else | ||
174 | +static int my_fcntl(int fd, int cmd, void *lck) | ||
175 | +{ | ||
176 | + int ret = tst_syscall(__NR_fcntl64, fd, cmd, lck); | ||
177 | + if (ret == -1) | ||
178 | + tst_brk(TBROK|TERRNO, "fcntl64"); | ||
179 | + return ret; | ||
180 | +} | ||
181 | +#endif | ||
182 | -- | ||
183 | 2.8.1 | ||
184 | |||
diff --git a/meta/recipes-extended/ltp/ltp_20180515.bb b/meta/recipes-extended/ltp/ltp_20180515.bb index 9cd3489722..ce86f7f14b 100644 --- a/meta/recipes-extended/ltp/ltp_20180515.bb +++ b/meta/recipes-extended/ltp/ltp_20180515.bb | |||
@@ -52,6 +52,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \ | |||
52 | file://0041-cve-2017-5669-shmat-for-0-or-PAGESIZE-with-RND-flag-.patch \ | 52 | file://0041-cve-2017-5669-shmat-for-0-or-PAGESIZE-with-RND-flag-.patch \ |
53 | file://0042-fs-ftest-ftest06.c-Fix-too-small-name-string-and-rel.patch \ | 53 | file://0042-fs-ftest-ftest06.c-Fix-too-small-name-string-and-rel.patch \ |
54 | file://0043-open-creat-skip-S_ISGID-check-on-files-created-by-no.patch \ | 54 | file://0043-open-creat-skip-S_ISGID-check-on-files-created-by-no.patch \ |
55 | file://0001-syscalls-fcntl-make-OFD-command-use-fcntl64-syscall-.patch \ | ||
55 | " | 56 | " |
56 | 57 | ||
57 | S = "${WORKDIR}/git" | 58 | S = "${WORKDIR}/git" |