aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-containers/criu/files/0004-criu-fix-conflicting-headers.patch
blob: f03f51dacdd664f489c8ac05ca76db3d42eb01e9 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
Backport patch to fix criu compile error with glibc 2.36. Update context
for Makefile.config.

Upstream-Status: Backport [https://github.com/checkpoint-restore/criu/commit/4c86d6a7]

Signed-off-by: Kai Kang <kai.kang@windriver.com>

From 4c86d6a7d54abb64fc5a15131f3351224e8c071b Mon Sep 17 00:00:00 2001
From: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Date: Sun, 31 Jul 2022 16:07:30 +0000
Subject: [PATCH] criu: fix conflicting headers

There are several changes in glibc 2.36 that make sys/mount.h header
incompatible with kernel headers:

https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E

This patch removes conflicting includes for `<linux/mount.h>` and
updates the content of `criu/include/linux/mount.h` to match
`/usr/include/sys/mount.h`. In addition, inline definitions sys_*()
functions have been moved from "linux/mount.h" to "syscall.h" to
avoid conflicts with `uapi/compel/plugins/std/syscall.h` and
`<unistd.h>`. The include for `<linux/aio_abi.h>` has been replaced
with local include to avoid conflicts with `<sys/mount.h>`.

Fixes: #1949

Upstream-Status: Inappropriate [embedded specific]

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
---
 Makefile.config              |  2 +-
 criu/cgroup.c                |  1 +
 criu/cr-check.c              |  2 +-
 criu/cr-restore.c            |  3 ++-
 criu/include/aio.h           |  2 +-
 criu/include/linux/aio_abi.h | 14 +++++++++++
 criu/include/linux/mount.h   | 48 +++++++++++++++++++-----------------
 criu/include/syscall.h       | 17 +++++++++++++
 criu/pie/parasite.c          |  2 +-
 criu/util.c                  |  1 +
 scripts/feature-tests.mak    | 13 ----------
 11 files changed, 64 insertions(+), 41 deletions(-)
 create mode 100644 criu/include/linux/aio_abi.h
 create mode 100644 criu/include/syscall.h

diff --git a/Makefile.config b/Makefile.config
index d113e2246..270ec61c0 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -78,7 +78,7 @@ export DEFINES += $(FEATURE_DEFINES)
 export CFLAGS += $(FEATURE_DEFINES)
 
 FEATURES_LIST	:= TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
-	SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW FSCONFIG MEMFD_CREATE OPENAT2
+	SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW MEMFD_CREATE OPENAT2
 
 # $1 - config name
 define gen-feature-test
diff --git a/criu/cgroup.c b/criu/cgroup.c
index e05b0832e..325df6a1d 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -27,6 +27,7 @@
 #include "images/cgroup.pb-c.h"
 #include "kerndat.h"
 #include "linux/mount.h"
+#include "syscall.h"
 
 /*
  * This structure describes set of controller groups
diff --git a/criu/cr-check.c b/criu/cr-check.c
index f589a91da..0ca80192c 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -21,7 +21,6 @@
 #include <sys/prctl.h>
 #include <sched.h>
 #include <sys/mount.h>
-#include <linux/aio_abi.h>
 
 #include "../soccr/soccr.h"
 
@@ -52,6 +51,7 @@
 #include "net.h"
 #include "restorer.h"
 #include "uffd.h"
+#include "linux/aio_abi.h"
 
 #include "images/inventory.pb-c.h"
 
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 279246c19..d11d28173 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -22,7 +22,6 @@
 #include <compel/ptrace.h>
 #include "common/compiler.h"
 
-#include "linux/mount.h"
 #include "linux/rseq.h"
 
 #include "clone-noasan.h"
@@ -86,6 +85,8 @@
 #include <compel/plugins/std/syscall-codes.h>
 #include "compel/include/asm/syscall.h"
 
+#include "linux/mount.h"
+
 #include "protobuf.h"
 #include "images/sa.pb-c.h"
 #include "images/timer.pb-c.h"
diff --git a/criu/include/aio.h b/criu/include/aio.h
index d1655739d..38e704020 100644
--- a/criu/include/aio.h
+++ b/criu/include/aio.h
@@ -1,7 +1,7 @@
 #ifndef __CR_AIO_H__
 #define __CR_AIO_H__
 
-#include <linux/aio_abi.h>
+#include "linux/aio_abi.h"
 #include "images/mm.pb-c.h"
 unsigned int aio_estimate_nr_reqs(unsigned int size);
 int dump_aio_ring(MmEntry *mme, struct vma_area *vma);
diff --git a/criu/include/linux/aio_abi.h b/criu/include/linux/aio_abi.h
new file mode 100644
index 000000000..d9ce78720
--- /dev/null
+++ b/criu/include/linux/aio_abi.h
@@ -0,0 +1,14 @@
+#ifndef __LINUX__AIO_ABI_H
+#define __LINUX__AIO_ABI_H
+
+typedef __kernel_ulong_t aio_context_t;
+
+/* read() from /dev/aio returns these structures. */
+struct io_event {
+	__u64 data; /* the data field from the iocb */
+	__u64 obj;  /* what iocb this event came from */
+	__s64 res;  /* result code for this event */
+	__s64 res2; /* secondary result */
+};
+
+#endif /* __LINUX__AIO_ABI_H */
diff --git a/criu/include/linux/mount.h b/criu/include/linux/mount.h
index 9a3a28b10..0d55a588c 100644
--- a/criu/include/linux/mount.h
+++ b/criu/include/linux/mount.h
@@ -4,32 +4,34 @@
 #include "common/config.h"
 #include "compel/plugins/std/syscall-codes.h"
 
-#ifdef CONFIG_HAS_FSCONFIG
-#include <linux/mount.h>
-#else
+/* Copied from /usr/include/sys/mount.h */
+
+#ifndef FSCONFIG_CMD_CREATE
+/* The type of fsconfig call made.   */
 enum fsconfig_command {
-	FSCONFIG_SET_FLAG = 0,	      /* Set parameter, supplying no value */
-	FSCONFIG_SET_STRING = 1,      /* Set parameter, supplying a string value */
-	FSCONFIG_SET_BINARY = 2,      /* Set parameter, supplying a binary blob value */
-	FSCONFIG_SET_PATH = 3,	      /* Set parameter, supplying an object by path */
-	FSCONFIG_SET_PATH_EMPTY = 4,  /* Set parameter, supplying an object by (empty) path */
-	FSCONFIG_SET_FD = 5,	      /* Set parameter, supplying an object by fd */
-	FSCONFIG_CMD_CREATE = 6,      /* Invoke superblock creation */
+	FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
+#define FSCONFIG_SET_FLAG FSCONFIG_SET_FLAG
+	FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */
+#define FSCONFIG_SET_STRING FSCONFIG_SET_STRING
+	FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */
+#define FSCONFIG_SET_BINARY FSCONFIG_SET_BINARY
+	FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */
+#define FSCONFIG_SET_PATH FSCONFIG_SET_PATH
+	FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */
+#define FSCONFIG_SET_PATH_EMPTY FSCONFIG_SET_PATH_EMPTY
+	FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */
+#define FSCONFIG_SET_FD FSCONFIG_SET_FD
+	FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */
+#define FSCONFIG_CMD_CREATE FSCONFIG_CMD_CREATE
 	FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */
+#define FSCONFIG_CMD_RECONFIGURE FSCONFIG_CMD_RECONFIGURE
 };
-#endif
+#endif // FSCONFIG_CMD_CREATE
 
-static inline int sys_fsopen(const char *fsname, unsigned int flags)
-{
-	return syscall(__NR_fsopen, fsname, flags);
-}
-static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux)
-{
-	return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
-}
-static inline int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags)
-{
-	return syscall(__NR_fsmount, fd, flags, attr_flags);
-}
+#ifndef MS_MGC_VAL
+/* Magic mount flag number. Has to be or-ed to the flag values.  */
+#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */
+#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */
+#endif
 
 #endif
diff --git a/criu/include/syscall.h b/criu/include/syscall.h
new file mode 100644
index 000000000..c38d6d971
--- /dev/null
+++ b/criu/include/syscall.h
@@ -0,0 +1,17 @@
+#ifndef __CR_SYSCALL_H__
+#define __CR_SYSCALL_H__
+
+static inline int sys_fsopen(const char *fsname, unsigned int flags)
+{
+	return syscall(__NR_fsopen, fsname, flags);
+}
+static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux)
+{
+	return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
+}
+static inline int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags)
+{
+	return syscall(__NR_fsmount, fd, flags, attr_flags);
+}
+
+#endif /* __CR_SYSCALL_H__ */
\ No newline at end of file
diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
index e7eb1fcb6..f75fe13bb 100644
--- a/criu/pie/parasite.c
+++ b/criu/pie/parasite.c
@@ -3,7 +3,6 @@
 #include <signal.h>
 #include <linux/limits.h>
 #include <linux/capability.h>
-#include <sys/mount.h>
 #include <stdarg.h>
 #include <sys/ioctl.h>
 #include <sys/uio.h>
@@ -14,6 +13,7 @@
 #include "int.h"
 #include "types.h"
 #include <compel/plugins/std/syscall.h>
+#include "linux/mount.h"
 #include "parasite.h"
 #include "fcntl.h"
 #include "prctl.h"
diff --git a/criu/util.c b/criu/util.c
index 5f69465b4..060ca3bd4 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -40,6 +40,7 @@
 #include "mem.h"
 #include "namespaces.h"
 #include "criu-log.h"
+#include "syscall.h"
 
 #include "clone-noasan.h"
 #include "cr_options.h"
diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak
index 014e893a8..fb5d2ef7a 100644
--- a/scripts/feature-tests.mak
+++ b/scripts/feature-tests.mak
@@ -137,19 +137,6 @@ ENTRY(main)
 END(main)
 endef
 
-define FEATURE_TEST_FSCONFIG
-
-#include <linux/mount.h>
-
-int main(void)
-{
-	if (FSCONFIG_CMD_CREATE > 0)
-		return 0;
-	return 0;
-}
-
-endef
-
 define FEATURE_TEST_NFTABLES_LIB_API_0
 
 #include <string.h>
-- 
2.34.1