From 02a6e4be2ff44344f58b078c18dc3ab3877fcfe5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 4 Apr 2022 15:19:42 +0900 Subject: kbuild: prevent exported headers from including , Some UAPI headers included , like this: #ifndef __KERNEL__ #include #endif As it turned out, they just included it for no good reason. After some fixes, now I can compile-test UAPI headers (CONFIG_UAPI_HEADER_TEST=y) without including from the system header search paths. To avoid somebody getting it back again, this commit adds the dummy header, usr/dummy-include/stdlib.h I added $(srctree)/usr/dummy-include to the header search paths. Because it is searched before the system directories, if someone tries to include , they will see the error message. While I am here, I also replaced $(objtree)/usr/include with $(obj), but it has no functional change. If we can make kernel headers self-contained (that is, none of exported kernel headers includes system headers), we will be able to add the -nostdinc flag, but that is much far from where we stand now. As a realistic solution, we can ban header inclusion individually by putting a dummy header into usr/dummy-include/. Currently, no header include . I put it as well before somebody attempts to use it. Signed-off-by: Masahiro Yamada Signed-off-by: Arnd Bergmann Reviewed-by: Greg Kroah-Hartman --- usr/include/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/include/Makefile') diff --git a/usr/include/Makefile b/usr/include/Makefile index fa9819e022b7..7740777b49f8 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -15,7 +15,7 @@ UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) # USERCFLAGS might contain sysroot location for CC. UAPI_CFLAGS += $(USERCFLAGS) -override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include +override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include # The following are excluded for now because they fail to build. # -- cgit v1.2.3 From 5c41778e9526227c2499e8a8fc614bb166b43734 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 4 Apr 2022 15:19:43 +0900 Subject: riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage I can compile this for ARCH=riscv with CONFIG_UAPI_HEADER_TEST=y. Signed-off-by: Masahiro Yamada Signed-off-by: Arnd Bergmann Reviewed-by: Christoph Hellwig --- usr/include/Makefile | 4 ---- 1 file changed, 4 deletions(-) (limited to 'usr/include/Makefile') diff --git a/usr/include/Makefile b/usr/include/Makefile index 7740777b49f8..a1a8403896cf 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -74,10 +74,6 @@ no-header-test += asm/stat.h no-header-test += linux/bpf_perf_event.h endif -ifeq ($(SRCARCH),riscv) -no-header-test += linux/bpf_perf_event.h -endif - ifeq ($(SRCARCH),sparc) no-header-test += asm/stat.h no-header-test += asm/uctx.h -- cgit v1.2.3 From 8c1a381a4fbbc99760d7352ec3c3fc75b7147c9b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 4 Apr 2022 15:19:44 +0900 Subject: mips: add asm/stat.h to UAPI compile-test coverage asm/stat.h is currently excluded from the UAPI compile-test for ARCH=mips because of the errors like follows: HDRTEST usr/include/asm/stat.h In file included from :32: ./usr/include/asm/stat.h:22:2: error: unknown type name 'ino_t' 22 | ino_t st_ino; | ^~~~~ ./usr/include/asm/stat.h:23:2: error: unknown type name 'mode_t' 23 | mode_t st_mode; | ^~~~~~ ./usr/include/asm/stat.h:25:2: error: unknown type name 'uid_t' 25 | uid_t st_uid; | ^~~~~ ./usr/include/asm/stat.h:26:2: error: unknown type name 'gid_t' 26 | gid_t st_gid; | ^~~~~ ./usr/include/asm/stat.h:58:2: error: unknown type name 'mode_t' 58 | mode_t st_mode; | ^~~~~~ ./usr/include/asm/stat.h:61:2: error: unknown type name 'uid_t' 61 | uid_t st_uid; | ^~~~~ ./usr/include/asm/stat.h:62:2: error: unknown type name 'gid_t' 62 | gid_t st_gid; | ^~~~~ The errors can be fixed by prefixing the types with __kernel_. Then, remove the no-header-test entry from user/include/Makefile. Signed-off-by: Masahiro Yamada Signed-off-by: Arnd Bergmann Reviewed-by: Christoph Hellwig --- usr/include/Makefile | 4 ---- 1 file changed, 4 deletions(-) (limited to 'usr/include/Makefile') diff --git a/usr/include/Makefile b/usr/include/Makefile index a1a8403896cf..da280bdcb391 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -65,10 +65,6 @@ no-header-test += asm/sigcontext.h no-header-test += linux/if_bonding.h endif -ifeq ($(SRCARCH),mips) -no-header-test += asm/stat.h -endif - ifeq ($(SRCARCH),powerpc) no-header-test += asm/stat.h no-header-test += linux/bpf_perf_event.h -- cgit v1.2.3 From c01013a2f8ddfbdddfff3e288a936be13948cf5d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 4 Apr 2022 15:19:45 +0900 Subject: powerpc: add asm/stat.h to UAPI compile-test coverage asm/stat.h is currently excluded from the UAPI compile-test for ARCH=powerpc because of the errors like follows: HDRTEST usr/include/asm/stat.h In file included from :32: ./usr/include/asm/stat.h:32:2: error: unknown type name 'ino_t' 32 | ino_t st_ino; | ^~~~~ ./usr/include/asm/stat.h:35:2: error: unknown type name 'mode_t' 35 | mode_t st_mode; | ^~~~~~ ./usr/include/asm/stat.h:40:2: error: unknown type name 'uid_t' 40 | uid_t st_uid; | ^~~~~ ./usr/include/asm/stat.h:41:2: error: unknown type name 'gid_t' 41 | gid_t st_gid; | ^~~~~ The errors can be fixed by prefixing the types with __kernel_. Then, remove the no-header-test entry from user/include/Makefile. Signed-off-by: Masahiro Yamada Signed-off-by: Arnd Bergmann Reviewed-by: Christoph Hellwig --- usr/include/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'usr/include/Makefile') diff --git a/usr/include/Makefile b/usr/include/Makefile index da280bdcb391..9d9dea32e3a0 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -66,7 +66,6 @@ no-header-test += linux/if_bonding.h endif ifeq ($(SRCARCH),powerpc) -no-header-test += asm/stat.h no-header-test += linux/bpf_perf_event.h endif -- cgit v1.2.3 From 31a088b664d6b0437faf00975b63b17e433aa916 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 4 Apr 2022 15:19:46 +0900 Subject: sparc: add asm/stat.h to UAPI compile-test coverage asm/stat.h is currently excluded from the UAPI compile-test for ARCH=sparc because of the errors like follows: In file included from : ./usr/include/asm/stat.h:11:2: error: unknown type name 'ino_t' 11 | ino_t st_ino; | ^~~~~ HDRTEST usr/include/asm/param.h ./usr/include/asm/stat.h:12:2: error: unknown type name 'mode_t' 12 | mode_t st_mode; | ^~~~~~ ./usr/include/asm/stat.h:14:2: error: unknown type name 'uid_t' 14 | uid_t st_uid; | ^~~~~ ./usr/include/asm/stat.h:15:2: error: unknown type name 'gid_t' 15 | gid_t st_gid; | ^~~~~ The errors can be fixed by prefixing the types with __kernel_. Then, remove the no-header-test entry from user/include/Makefile. Signed-off-by: Masahiro Yamada Signed-off-by: Arnd Bergmann Reviewed-by: Christoph Hellwig --- usr/include/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'usr/include/Makefile') diff --git a/usr/include/Makefile b/usr/include/Makefile index 9d9dea32e3a0..e2615b9b0402 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -70,7 +70,6 @@ no-header-test += linux/bpf_perf_event.h endif ifeq ($(SRCARCH),sparc) -no-header-test += asm/stat.h no-header-test += asm/uctx.h no-header-test += asm/fbio.h endif -- cgit v1.2.3