]>
Commit | Line | Data |
---|---|---|
2123b457 JP |
1 | From 4c86d6a7d54abb64fc5a15131f3351224e8c071b Mon Sep 17 00:00:00 2001 |
2 | From: Radostin Stoyanov <rstoyanov@fedoraproject.org> | |
3 | Date: Sun, 31 Jul 2022 16:07:30 +0000 | |
4 | Subject: [PATCH] criu: fix conflicting headers | |
5 | ||
6 | There are several changes in glibc 2.36 that make sys/mount.h header | |
7 | incompatible with kernel headers: | |
8 | ||
9 | https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E | |
10 | ||
11 | This patch removes conflicting includes for `<linux/mount.h>` and | |
12 | updates the content of `criu/include/linux/mount.h` to match | |
13 | `/usr/include/sys/mount.h`. In addition, inline definitions sys_*() | |
14 | functions have been moved from "linux/mount.h" to "syscall.h" to | |
15 | avoid conflicts with `uapi/compel/plugins/std/syscall.h` and | |
16 | `<unistd.h>`. The include for `<linux/aio_abi.h>` has been replaced | |
17 | with local include to avoid conflicts with `<sys/mount.h>`. | |
18 | ||
19 | Fixes: #1949 | |
20 | ||
21 | Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org> | |
22 | --- | |
23 | Makefile.config | 2 +- | |
24 | criu/cgroup.c | 1 + | |
25 | criu/cr-check.c | 2 +- | |
26 | criu/cr-restore.c | 3 ++- | |
27 | criu/include/aio.h | 2 +- | |
28 | criu/include/linux/aio_abi.h | 14 +++++++++++ | |
29 | criu/include/linux/mount.h | 48 +++++++++++++++++++----------------- | |
30 | criu/include/syscall.h | 17 +++++++++++++ | |
31 | criu/pie/parasite.c | 2 +- | |
32 | criu/util.c | 1 + | |
33 | scripts/feature-tests.mak | 13 ---------- | |
34 | 11 files changed, 64 insertions(+), 41 deletions(-) | |
35 | create mode 100644 criu/include/linux/aio_abi.h | |
36 | create mode 100644 criu/include/syscall.h | |
37 | ||
38 | diff --git a/Makefile.config b/Makefile.config | |
39 | index d113e2246b..270ec61c0f 100644 | |
40 | --- a/Makefile.config | |
41 | +++ b/Makefile.config | |
42 | @@ -78,7 +78,7 @@ export DEFINES += $(FEATURE_DEFINES) | |
43 | export CFLAGS += $(FEATURE_DEFINES) | |
44 | ||
45 | FEATURES_LIST := TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \ | |
46 | - SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW FSCONFIG MEMFD_CREATE OPENAT2 | |
47 | + SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW MEMFD_CREATE OPENAT2 | |
48 | ||
49 | # $1 - config name | |
50 | define gen-feature-test | |
51 | diff --git a/criu/cgroup.c b/criu/cgroup.c | |
52 | index e05b0832ed..325df6a1db 100644 | |
53 | --- a/criu/cgroup.c | |
54 | +++ b/criu/cgroup.c | |
55 | @@ -27,6 +27,7 @@ | |
56 | #include "images/cgroup.pb-c.h" | |
57 | #include "kerndat.h" | |
58 | #include "linux/mount.h" | |
59 | +#include "syscall.h" | |
60 | ||
61 | /* | |
62 | * This structure describes set of controller groups | |
63 | diff --git a/criu/cr-check.c b/criu/cr-check.c | |
64 | index f589a91da1..0ca80192ce 100644 | |
65 | --- a/criu/cr-check.c | |
66 | +++ b/criu/cr-check.c | |
67 | @@ -21,7 +21,6 @@ | |
68 | #include <sys/prctl.h> | |
69 | #include <sched.h> | |
70 | #include <sys/mount.h> | |
71 | -#include <linux/aio_abi.h> | |
72 | ||
73 | #include "../soccr/soccr.h" | |
74 | ||
75 | @@ -52,6 +51,7 @@ | |
76 | #include "net.h" | |
77 | #include "restorer.h" | |
78 | #include "uffd.h" | |
79 | +#include "linux/aio_abi.h" | |
80 | ||
81 | #include "images/inventory.pb-c.h" | |
82 | ||
83 | diff --git a/criu/cr-restore.c b/criu/cr-restore.c | |
84 | index 279246c190..d11d28173a 100644 | |
85 | --- a/criu/cr-restore.c | |
86 | +++ b/criu/cr-restore.c | |
87 | @@ -22,7 +22,6 @@ | |
88 | #include <compel/ptrace.h> | |
89 | #include "common/compiler.h" | |
90 | ||
91 | -#include "linux/mount.h" | |
92 | #include "linux/rseq.h" | |
93 | ||
94 | #include "clone-noasan.h" | |
95 | @@ -86,6 +85,8 @@ | |
96 | #include <compel/plugins/std/syscall-codes.h> | |
97 | #include "compel/include/asm/syscall.h" | |
98 | ||
99 | +#include "linux/mount.h" | |
100 | + | |
101 | #include "protobuf.h" | |
102 | #include "images/sa.pb-c.h" | |
103 | #include "images/timer.pb-c.h" | |
104 | diff --git a/criu/include/aio.h b/criu/include/aio.h | |
105 | index d1655739d9..38e7040209 100644 | |
106 | --- a/criu/include/aio.h | |
107 | +++ b/criu/include/aio.h | |
108 | @@ -1,7 +1,7 @@ | |
109 | #ifndef __CR_AIO_H__ | |
110 | #define __CR_AIO_H__ | |
111 | ||
112 | -#include <linux/aio_abi.h> | |
113 | +#include "linux/aio_abi.h" | |
114 | #include "images/mm.pb-c.h" | |
115 | unsigned int aio_estimate_nr_reqs(unsigned int size); | |
116 | int dump_aio_ring(MmEntry *mme, struct vma_area *vma); | |
117 | diff --git a/criu/include/linux/aio_abi.h b/criu/include/linux/aio_abi.h | |
118 | new file mode 100644 | |
119 | index 0000000000..d9ce787203 | |
120 | --- /dev/null | |
121 | +++ b/criu/include/linux/aio_abi.h | |
122 | @@ -0,0 +1,14 @@ | |
123 | +#ifndef __LINUX__AIO_ABI_H | |
124 | +#define __LINUX__AIO_ABI_H | |
125 | + | |
126 | +typedef __kernel_ulong_t aio_context_t; | |
127 | + | |
128 | +/* read() from /dev/aio returns these structures. */ | |
129 | +struct io_event { | |
130 | + __u64 data; /* the data field from the iocb */ | |
131 | + __u64 obj; /* what iocb this event came from */ | |
132 | + __s64 res; /* result code for this event */ | |
133 | + __s64 res2; /* secondary result */ | |
134 | +}; | |
135 | + | |
136 | +#endif /* __LINUX__AIO_ABI_H */ | |
137 | diff --git a/criu/include/linux/mount.h b/criu/include/linux/mount.h | |
138 | index 9a3a28b100..0d55a588cb 100644 | |
139 | --- a/criu/include/linux/mount.h | |
140 | +++ b/criu/include/linux/mount.h | |
141 | @@ -4,32 +4,34 @@ | |
142 | #include "common/config.h" | |
143 | #include "compel/plugins/std/syscall-codes.h" | |
144 | ||
145 | -#ifdef CONFIG_HAS_FSCONFIG | |
146 | -#include <linux/mount.h> | |
147 | -#else | |
148 | +/* Copied from /usr/include/sys/mount.h */ | |
149 | + | |
150 | +#ifndef FSCONFIG_CMD_CREATE | |
151 | +/* The type of fsconfig call made. */ | |
152 | enum fsconfig_command { | |
153 | - FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
154 | - FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ | |
155 | - FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ | |
156 | - FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ | |
157 | - FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ | |
158 | - FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ | |
159 | - FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ | |
160 | + FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
161 | +#define FSCONFIG_SET_FLAG FSCONFIG_SET_FLAG | |
162 | + FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ | |
163 | +#define FSCONFIG_SET_STRING FSCONFIG_SET_STRING | |
164 | + FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ | |
165 | +#define FSCONFIG_SET_BINARY FSCONFIG_SET_BINARY | |
166 | + FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ | |
167 | +#define FSCONFIG_SET_PATH FSCONFIG_SET_PATH | |
168 | + FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ | |
169 | +#define FSCONFIG_SET_PATH_EMPTY FSCONFIG_SET_PATH_EMPTY | |
170 | + FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ | |
171 | +#define FSCONFIG_SET_FD FSCONFIG_SET_FD | |
172 | + FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ | |
173 | +#define FSCONFIG_CMD_CREATE FSCONFIG_CMD_CREATE | |
174 | FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ | |
175 | +#define FSCONFIG_CMD_RECONFIGURE FSCONFIG_CMD_RECONFIGURE | |
176 | }; | |
177 | -#endif | |
178 | +#endif // FSCONFIG_CMD_CREATE | |
179 | ||
180 | -static inline int sys_fsopen(const char *fsname, unsigned int flags) | |
181 | -{ | |
182 | - return syscall(__NR_fsopen, fsname, flags); | |
183 | -} | |
184 | -static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux) | |
185 | -{ | |
186 | - return syscall(__NR_fsconfig, fd, cmd, key, value, aux); | |
187 | -} | |
188 | -static inline int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags) | |
189 | -{ | |
190 | - return syscall(__NR_fsmount, fd, flags, attr_flags); | |
191 | -} | |
192 | +#ifndef MS_MGC_VAL | |
193 | +/* Magic mount flag number. Has to be or-ed to the flag values. */ | |
194 | +#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ | |
195 | +#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */ | |
196 | +#endif | |
197 | ||
198 | #endif | |
199 | diff --git a/criu/include/syscall.h b/criu/include/syscall.h | |
200 | new file mode 100644 | |
201 | index 0000000000..c38d6d971b | |
202 | --- /dev/null | |
203 | +++ b/criu/include/syscall.h | |
204 | @@ -0,0 +1,17 @@ | |
205 | +#ifndef __CR_SYSCALL_H__ | |
206 | +#define __CR_SYSCALL_H__ | |
207 | + | |
208 | +static inline int sys_fsopen(const char *fsname, unsigned int flags) | |
209 | +{ | |
210 | + return syscall(__NR_fsopen, fsname, flags); | |
211 | +} | |
212 | +static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux) | |
213 | +{ | |
214 | + return syscall(__NR_fsconfig, fd, cmd, key, value, aux); | |
215 | +} | |
216 | +static inline int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags) | |
217 | +{ | |
218 | + return syscall(__NR_fsmount, fd, flags, attr_flags); | |
219 | +} | |
220 | + | |
221 | +#endif /* __CR_SYSCALL_H__ */ | |
222 | \ No newline at end of file | |
223 | diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c | |
224 | index e7eb1fcb60..f75fe13bb6 100644 | |
225 | --- a/criu/pie/parasite.c | |
226 | +++ b/criu/pie/parasite.c | |
227 | @@ -3,7 +3,6 @@ | |
228 | #include <signal.h> | |
229 | #include <linux/limits.h> | |
230 | #include <linux/capability.h> | |
231 | -#include <sys/mount.h> | |
232 | #include <stdarg.h> | |
233 | #include <sys/ioctl.h> | |
234 | #include <sys/uio.h> | |
235 | @@ -14,6 +13,7 @@ | |
236 | #include "int.h" | |
237 | #include "types.h" | |
238 | #include <compel/plugins/std/syscall.h> | |
239 | +#include "linux/mount.h" | |
240 | #include "parasite.h" | |
241 | #include "fcntl.h" | |
242 | #include "prctl.h" | |
243 | diff --git a/criu/util.c b/criu/util.c | |
244 | index 5f69465b44..060ca3bd44 100644 | |
245 | --- a/criu/util.c | |
246 | +++ b/criu/util.c | |
247 | @@ -40,6 +40,7 @@ | |
248 | #include "mem.h" | |
249 | #include "namespaces.h" | |
250 | #include "criu-log.h" | |
251 | +#include "syscall.h" | |
252 | ||
253 | #include "clone-noasan.h" | |
254 | #include "cr_options.h" | |
255 | diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak | |
256 | index 014e893a84..fb5d2ef7ad 100644 | |
257 | --- a/scripts/feature-tests.mak | |
258 | +++ b/scripts/feature-tests.mak | |
259 | @@ -137,19 +137,6 @@ ENTRY(main) | |
260 | END(main) | |
261 | endef | |
262 | ||
263 | -define FEATURE_TEST_FSCONFIG | |
264 | - | |
265 | -#include <linux/mount.h> | |
266 | - | |
267 | -int main(void) | |
268 | -{ | |
269 | - if (FSCONFIG_CMD_CREATE > 0) | |
270 | - return 0; | |
271 | - return 0; | |
272 | -} | |
273 | - | |
274 | -endef | |
275 | - | |
276 | define FEATURE_TEST_NFTABLES_LIB_API_0 | |
277 | ||
278 | #include <string.h> | |
279 | From 517c0947050e63aac72f63a3bf373d76264723b9 Mon Sep 17 00:00:00 2001 | |
280 | From: Radostin Stoyanov <rstoyanov@fedoraproject.org> | |
281 | Date: Wed, 24 Aug 2022 21:20:30 +0200 | |
282 | Subject: [PATCH] mount: add definition for FSOPEN_CLOEXEC | |
283 | ||
284 | A recent change in glibc introduced `enum fsconfig_command` [1] and as a | |
285 | result the compilation of criu fails with the following errors | |
286 | ||
287 | In file included from criu/pie/util.c:3: | |
288 | /usr/include/sys/mount.h:240:6: error: redeclaration of 'enum fsconfig_command' | |
289 | 240 | enum fsconfig_command | |
290 | | ^~~~~~~~~~~~~~~~ | |
291 | In file included from /usr/include/sys/mount.h:32: | |
292 | criu/include/linux/mount.h:11:6: note: originally defined here | |
293 | 11 | enum fsconfig_command { | |
294 | | ^~~~~~~~~~~~~~~~ | |
295 | /usr/include/sys/mount.h:242:3: error: redeclaration of enumerator 'FSCONFIG_SET_FLAG' | |
296 | 242 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
297 | | ^~~~~~~~~~~~~~~~~ | |
298 | criu/include/linux/mount.h:12:9: note: previous definition of 'FSCONFIG_SET_FLAG' with type 'enum fsconfig_command' | |
299 | 12 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
300 | | ^~~~~~~~~~~~~~~~~ | |
301 | /usr/include/sys/mount.h:244:3: error: redeclaration of enumerator 'FSCONFIG_SET_STRING' | |
302 | 244 | FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ | |
303 | | ^~~~~~~~~~~~~~~~~~~ | |
304 | criu/include/linux/mount.h:14:9: note: previous definition of 'FSCONFIG_SET_STRING' with type 'enum fsconfig_command' | |
305 | 14 | FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ | |
306 | | ^~~~~~~~~~~~~~~~~~~ | |
307 | /usr/include/sys/mount.h:246:3: error: redeclaration of enumerator 'FSCONFIG_SET_BINARY' | |
308 | 246 | FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ | |
309 | | ^~~~~~~~~~~~~~~~~~~ | |
310 | criu/include/linux/mount.h:16:9: note: previous definition of 'FSCONFIG_SET_BINARY' with type 'enum fsconfig_command' | |
311 | 16 | FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ | |
312 | | ^~~~~~~~~~~~~~~~~~~ | |
313 | /usr/include/sys/mount.h:248:3: error: redeclaration of enumerator 'FSCONFIG_SET_PATH' | |
314 | 248 | FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ | |
315 | | ^~~~~~~~~~~~~~~~~ | |
316 | criu/include/linux/mount.h:18:9: note: previous definition of 'FSCONFIG_SET_PATH' with type 'enum fsconfig_command' | |
317 | 18 | FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ | |
318 | | ^~~~~~~~~~~~~~~~~ | |
319 | /usr/include/sys/mount.h:250:3: error: redeclaration of enumerator 'FSCONFIG_SET_PATH_EMPTY' | |
320 | 250 | FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ | |
321 | | ^~~~~~~~~~~~~~~~~~~~~~~ | |
322 | criu/include/linux/mount.h:20:9: note: previous definition of 'FSCONFIG_SET_PATH_EMPTY' with type 'enum fsconfig_command' | |
323 | 20 | FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ | |
324 | | ^~~~~~~~~~~~~~~~~~~~~~~ | |
325 | /usr/include/sys/mount.h:252:3: error: redeclaration of enumerator 'FSCONFIG_SET_FD' | |
326 | 252 | FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ | |
327 | | ^~~~~~~~~~~~~~~ | |
328 | criu/include/linux/mount.h:22:9: note: previous definition of 'FSCONFIG_SET_FD' with type 'enum fsconfig_command' | |
329 | 22 | FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ | |
330 | | ^~~~~~~~~~~~~~~ | |
331 | /usr/include/sys/mount.h:254:3: error: redeclaration of enumerator 'FSCONFIG_CMD_CREATE' | |
332 | 254 | FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ | |
333 | | ^~~~~~~~~~~~~~~~~~~ | |
334 | criu/include/linux/mount.h:24:9: note: previous definition of 'FSCONFIG_CMD_CREATE' with type 'enum fsconfig_command' | |
335 | 24 | FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ | |
336 | | ^~~~~~~~~~~~~~~~~~~ | |
337 | /usr/include/sys/mount.h:256:3: error: redeclaration of enumerator 'FSCONFIG_CMD_RECONFIGURE' | |
338 | 256 | FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ | |
339 | | ^~~~~~~~~~~~~~~~~~~~~~~~ | |
340 | criu/include/linux/mount.h:26:9: note: previous definition of 'FSCONFIG_CMD_RECONFIGURE' with type 'enum fsconfig_command' | |
341 | 26 | FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ | |
342 | ||
343 | This patch adds definition for FSOPEN_CLOEXEC to solve this problem. In particular, | |
344 | sys/mount.h includes ifndef check for FSOPEN_CLOEXEC surrounding `enum fsconfig_command`. | |
345 | ||
346 | [1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=7eae6a91e9b1670330c9f15730082c91c0b1d570 | |
347 | ||
348 | Reported-by: Younes Manton (@ymanton) | |
349 | Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org> | |
350 | --- | |
351 | criu/include/linux/mount.h | 10 ++++++++-- | |
352 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
353 | ||
354 | diff --git a/criu/include/linux/mount.h b/criu/include/linux/mount.h | |
355 | index 0d55a588cb..fefafa89e1 100644 | |
356 | --- a/criu/include/linux/mount.h | |
357 | +++ b/criu/include/linux/mount.h | |
358 | @@ -6,7 +6,7 @@ | |
359 | ||
360 | /* Copied from /usr/include/sys/mount.h */ | |
361 | ||
362 | -#ifndef FSCONFIG_CMD_CREATE | |
363 | +#ifndef FSOPEN_CLOEXEC | |
364 | /* The type of fsconfig call made. */ | |
365 | enum fsconfig_command { | |
366 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
367 | @@ -26,7 +26,13 @@ enum fsconfig_command { | |
368 | FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ | |
369 | #define FSCONFIG_CMD_RECONFIGURE FSCONFIG_CMD_RECONFIGURE | |
370 | }; | |
371 | -#endif // FSCONFIG_CMD_CREATE | |
372 | + | |
373 | +#endif // FSOPEN_CLOEXEC | |
374 | + | |
375 | +/* fsopen flags. With the redundant definition, we check if the kernel, | |
376 | + * glibc value and our value still match. | |
377 | + */ | |
378 | +#define FSOPEN_CLOEXEC 0x00000001 | |
379 | ||
380 | #ifndef MS_MGC_VAL | |
381 | /* Magic mount flag number. Has to be or-ed to the flag values. */ |