selftests/empty_mntns: fix header conflicts and remove TOOLS_INCLUDES
PATCH 1/2 selftests/empty_mntns: fix header conflicts and remove TOOLS_INCLUDES
Including <linux/mount.h> alongside <sys/mount.h> in empty_mntns test files leads to compilation errors with glibc due to conflicting enum definitions of MS_RDONLY and other mount flags.
Additionally, passing $(TOOLS_INCLUDES) (-isystem tools/include/uapi) causes tools/include/uapi/linux/types.h to be included, forcing int-ll64.h definitions on architectures like PowerPC (ppc64le) that use int-l64.h, resulting in type collisions with system headers.
Fix this by:
- Dropping <linux/mount.h> from the test sources in favor of <sys/mount.h> (with <linux/stat.h> included after system headers).
- Removing $(TOOLS_INCLUDES) from the Makefile since standard UAPI headers are already supplied via $(KHDR_INCLUDES).
--- tools/testing/selftests/filesystems/empty_mntns/Makefile | 2 +- .../filesystems/empty_mntns/clone3_empty_mntns_test.c | 3 +-- .../selftests/filesystems/empty_mntns/empty_mntns_test.c | 3 +-- .../selftests/filesystems/empty_mntns/overmount_chroot_test.c | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-)
tools/testing/selftests/filesystems/empty_mntns/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later -CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES) +CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) LDLIBS += -lcap TEST_GEN_PROGS := empty_mntns_test overmount_chroot_test clone3_empty_mntns_test
tools/testing/selftests/filesystems/empty_mntns/clone3_empty_mntns_test.c +1 -2
@@ -15,14 +15,13 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <stdio.h> #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "../wrappers.h"
tools/testing/selftests/filesystems/empty_mntns/empty_mntns_test.c +1 -2
@@ -7,8 +7,6 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <sched.h> #include <stdio.h> #include <string.h>
@@ -17,6 +15,7 @@#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "../wrappers.h"
tools/testing/selftests/filesystems/empty_mntns/overmount_chroot_test.c +1 -2
@@ -18,8 +18,6 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <sched.h> #include <stdio.h> #include <string.h>
@@ -29,6 +27,7 @@#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "empty_mntns.h"
Signature · 1 line
2.45.1
PATCH 2/2 selftests/empty_mntns: use unused bit in unknown_flags_rejected test
The unknown_flags_rejected test uses 0x800000000ULL (1ULL << 35) to test that clone3() rejects unknown 64-bit flags with -EINVAL.
However, bit 35 has been allocated to CLONE_NNP, causing clone3() to succeed and the assertion expecting failure to fail.
Switch to (1ULL << 63) which is an unused high bit so the test consistently expects -EINVAL.
--- .../selftests/filesystems/empty_mntns/clone3_empty_mntns_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filesystems/empty_mntns/clone3_empty_mntns_test.c +1 -1
@@ -868,7 +868,7 @@ TEST(unknown_flags_rejected)if (pid ==0 ) {struct __clone_args args = { - .flags =0x800000000ULL , + .flags = (1ULL <<63 ), .exit_signal =SIGCHLD , };pid_t ret;
Signature · 1 line
2.45.1
Hi Christian,
Gentle ping on this series. Could you please review it, and if it looks fine, pick it up?
Quoted 99 lines · Disha Goel
Including <
linux/mount.h> alongside <sys/mount.h> inempty_mntnstest files leads to compilation errors with glibc due to conflicting enum definitions ofMS_RDONLYand other mount flags.Additionally, passing $(TOOLS_INCLUDES) (-isystem
tools/include/uapi) causestools/include/uapi/linux/types.hto be included, forcingint-ll64.hdefinitions on architectures like PowerPC (ppc64le) that useint-l64.h, resulting in type collisions with system headers.Fix this by:
- Dropping <linux/mount.h> from the test sources in favor of <sys/mount.h> (with <linux/stat.h> included after system headers).
- Removing $(TOOLS_INCLUDES) from theMakefilesince standard UAPI headers are already supplied via $(KHDR_INCLUDES).Fixes 32f54f2bbccf ("selftests/filesystems: add tests for empty mount namespaces")Fixes 5b8ffd63fbd9 ("selftests/filesystems: add clone3 tests for empty mount namespaces")Signed-off-by Disha Goel <[email protected]>--- tools/testing/selftests/filesystems/empty_mntns/Makefile | 2 +- .../filesystems/empty_mntns/clone3_empty_mntns_test.c | 3 +-- .../selftests/filesystems/empty_mntns/empty_mntns_test.c | 3 +-- .../selftests/filesystems/empty_mntns/overmount_chroot_test.c | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-)tools/testing/selftests/filesystems/empty_mntns/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later -CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES) +CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES) LDLIBS += -lcap TEST_GEN_PROGS := empty_mntns_test overmount_chroot_test clone3_empty_mntns_testtools/testing/selftests/filesystems/empty_mntns/clone3_empty_mntns_test.c +1
-2@@ -15,14 +15,13 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <stdio.h> #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "../wrappers.h" tools/testing/selftests/filesystems/empty_mntns/empty_mntns_test.c +1
-2@@ -7,8 +7,6 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <sched.h> #include <stdio.h> #include <string.h> @@ -17,6 +15,7 @@#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "../wrappers.h" tools/testing/selftests/filesystems/empty_mntns/overmount_chroot_test.c +1
-2@@ -18,8 +18,6 @@#define _GNU_SOURCE#include <fcntl.h> -#include <linux/mount.h> -#include <linux/stat.h> #include <sched.h> #include <stdio.h> #include <string.h> @@ -29,6 +27,7 @@#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <linux/stat.h> #include "../utils.h" #include "empty_mntns.h"
Signature · 2 lines
Regards, Disha
Christian Brauner
maintainerQuoted 3 lines · Disha Goel
Including <
linux/mount.h> alongside <sys/mount.h> inempty_mntnstest files leads to compilation errors with glibc due to conflicting enum definitions ofMS_RDONLYand other mount flags.
That part is fine. Note that ../wrappers.h still pulls in <linux/mount.h>, so what actually fixes this is that <sys/mount.h> now comes first.
Quoted 7 lines
Additionally, passing $(TOOLS_INCLUDES) (-isystem
tools/include/uapi) causestools/include/uapi/linux/types.hto be included, forcingint-ll64.hdefinitions on architectures like PowerPC (ppc64le) that useint-l64.h, resulting in type collisions with system headers.- Removing $(TOOLS_INCLUDES) from the
Makefilesince standard UAPI headers are already supplied via $(KHDR_INCLUDES).
No, please drop this hunk. $(TOOLS_INCLUDES) is there so the tests build without a headers_install and filesystems/statmount, pidfd and namespaces use it the same way. The int-ll64.h vs int-l64.h clash you hit is in tools/include/uapi/linux/types.h and only shows up when the kernel headers aren't installed. Fix it there, not by dropping the include path in one directory.