Skip to content

Commit 9e2276f

Browse files
zeddiisuryasaimadhu
authored andcommitted
arch/x86/boot: Use prefix map to avoid embedded paths
It was observed that the kernel embeds the absolute build path in the x86 boot image when the __FILE__ macro is expanded. > From https://bugzilla.yoctoproject.org/show_bug.cgi?id=13458: If you turn on the buildpaths QA test, or try a reproducible build, you discover that the kernel image contains build paths. $ strings bzImage-5.0.19-yocto-standard |grep tmp/ out of pgt_buf in /data/poky-tmp/reproducible/tmp/work-shared/qemux86-64/kernel-source/arch/x86/boot/compressed/kaslr_64.c!? But what's this in the top-level Makefile: $ git grep prefix-map Makefile:KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) So the __FILE__ shouldn't be using the full path. However arch/x86/boot/compressed/Makefile has this: KBUILD_CFLAGS := -m$(BITS) -O2 So that clears KBUILD_FLAGS, removing the -fmacro-prefix-map option. Use -fmacro-prefix-map to have relative paths in the boot image too. [ bp: Massage commit message and put the KBUILD_CFLAGS addition in ..boot/Makefile after the KBUILD_AFLAGS assignment because gas doesn't support -fmacro-prefix-map. ] Signed-off-by: Bruce Ashfield <[email protected]> Signed-off-by: Ross Burton <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: George Rimar <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: https://bugzilla.kernel.org/show_bug.cgi?id=204333
1 parent 54ecb8f commit 9e2276f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

arch/x86/boot/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ clean-files += cpustr.h
6767

6868
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
6969
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
70+
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
7071
GCOV_PROFILE := n
7172
UBSAN_SANITIZE := n
7273

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
3838
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
3939
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
4040
KBUILD_CFLAGS += -Wno-pointer-sign
41+
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
4142

4243
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
4344
GCOV_PROFILE := n

0 commit comments

Comments
 (0)