Salted build ids via ELF notes
v6 cover Salted build ids via ELF notes
Hi,
This is v6 of the series to allow unique build ids. v6 is mostly minor fixups and Acks for this to go through the kbuild tree.
Thanks,
Laura
Laura Abbott (4):
kbuild: Add build salt to the kernel and modules
x86: Add build salt to the vDSO
powerpc: Add build salt to the vDSO
arm64: Add build salt to the vDSO
arch/arm64/kernel/vdso/note.S | 3 +++ arch/powerpc/kernel/vdso32/note.S | 3 +++ arch/x86/entry/vdso/vdso-note.S | 3 +++ arch/x86/entry/vdso/vdso32/note.S | 3 +++ include/linux/build-salt.h | 20 ++++++++++++++++++++ init/Kconfig | 9 +++++++++ init/version.c | 3 +++ scripts/mod/modpost.c | 3 +++ 8 files changed, 47 insertions(+) create mode 100644 include/linux/build-salt.h
Signature · 1 line
2.17.1
PATCH v6 1/4 kbuild: Add build salt to the kernel and modules
In Fedora, the debug information is packaged separately (foo-debuginfo) and can be installed separately. There's been a long standing issue where only one version of a debuginfo info package can be installed at a time. There's been an effort for Fedora for parallel debuginfo to rectify this problem.
Part of the requirement to allow parallel debuginfo to work is that build ids are unique between builds. The existing upstream rpm implementation ensures this by re-calculating the build-id using the version and release as a seed. This doesn't work 100% for the kernel because of the vDSO which is its own binary and doesn't get updated when embedded.
Fix this by adding some data in an ELF note for both the kernel and modules. The data is controlled via a Kconfig option so distributions can set it to an appropriate value to ensure uniqueness between builds.
---
v6: Added more detail to the commit text about why exactly this feature is useful. Default string now ""
--- include/linux/build-salt.h | 20 ++++++++++++++++++++ init/Kconfig | 9 +++++++++ init/version.c | 3 +++ scripts/mod/modpost.c | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 include/linux/build-salt.h
include/linux/build-salt.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __BUILD_SALT_H +#define __BUILD_SALT_H + +#include <linux/elfnote.h> + +#define LINUX_ELFNOTE_BUILD_SALT 0x100 + +#ifdef __ASSEMBLER__ + +#define BUILD_SALT \ + ELFNOTE(Linux, LINUX_ELFNOTE_BUILD_SALT, .asciz CONFIG_BUILD_SALT) + +#else + +#define BUILD_SALT \ + ELFNOTE32("Linux", LINUX_ELFNOTE_BUILD_SALT, CONFIG_BUILD_SALT) + +#endif + +#endif /* __BUILD_SALT_H */
init/Kconfig +9 -0
@@ -107,6 +107,15 @@ config LOCALVERSION_AUTO which is done within the script "scripts/setlocalversion".) +config BUILD_SALT + string "Build ID Salt" + default "" + help + The build ID is used to link binaries and their debug info. Setting + this option will use the value in the calculation of the build id. + This is mostly useful for distributions which want to ensure the + build is unique between builds. It's safe to leave the default. + config HAVE_KERNEL_GZIP bool
init/version.c +3 -0
@@ -7,6 +7,7 @@*/ #include <generated/compile.h> +#include <linux/build-salt.h> #include <linux/export.h> #include <linux/uts.h> #include <linux/utsname.h>
@@ -49,3 +50,5 @@ const char linux_proc_banner[] ="%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" " (" LINUX_COMPILER ") %s\n" ; + +BUILD_SALT ;
scripts/mod/modpost.c +3 -0
@@ -2125,10 +2125,13 @@ static int check_modname_len(struct module *mod)**/ static void add_header (struct buffer *b,struct module *mod) { +buf_printf (b,"#include <linux/build-salt.h>\n" );buf_printf (b,"#include <linux/module.h>\n" );buf_printf (b,"#include <linux/vermagic.h>\n" );buf_printf (b,"#include <linux/compiler.h>\n" );buf_printf (b,"\n" ); +buf_printf (b,"BUILD_SALT;\n" ); +buf_printf (b,"\n" );buf_printf (b,"MODULE_INFO(vermagic, VERMAGIC_STRING);\n" );buf_printf (b,"MODULE_INFO(name, KBUILD_MODNAME);\n" );buf_printf (b,"\n" );
Signature · 1 line
2.17.1
PATCH v6 2/4 x86: Add build salt to the vDSO
In reply to Laura AbbottThe vDSO needs to have a unique build id in a similar manner to the kernel and modules. Use the build salt macro.
---
v6: Ack from Andy
--- arch/x86/entry/vdso/vdso-note.S | 3 +++ arch/x86/entry/vdso/vdso32/note.S | 3 +++ 2 files changed, 6 insertions(+)
arch/x86/entry/vdso/vdso-note.S +3 -0
@@ -3,6 +3,7 @@ * Here we can supply some information useful to userland. */ +#include <linux/build-salt.h> #include <linux/uts.h> #include <linux/version.h> #include <linux/elfnote.h>
@@ -10,3 +11,5 @@ ELFNOTE_START(Linux, 0, "a") .long LINUX_VERSION_CODE ELFNOTE_END + +BUILD_SALT
arch/x86/entry/vdso/vdso32/note.S +3 -0
@@ -4,6 +4,7 @@ * Here we can supply some information useful to userland. */ +#include <linux/build-salt.h> #include <linux/version.h> #include <linux/elfnote.h>
@@ -14,6 +15,8 @@ ELFNOTE_START(Linux, 0, "a") .long LINUX_VERSION_CODE ELFNOTE_END +BUILD_SALT + #ifdef CONFIG_XEN /* * Add a special note telling glibc's dynamic linker a fake hardware
Signature · 1 line
2.17.1
PATCH v6 3/4 powerpc: Add build salt to the vDSO
In reply to Laura AbbottThe vDSO needs to have a unique build id in a similar manner to the kernel and modules. Use the build salt macro.
---
v6: Remove semi-colon
--- arch/powerpc/kernel/vdso32/note.S | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/vdso32/note.S +3 -0
@@ -5,6 +5,7 @@ #include <linux/uts.h> #include <linux/version.h> +#include <linux/build-salt.h> #define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type) \ .section name, flags; \
@@ -23,3 +24,5 @@ ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0) .long LINUX_VERSION_CODE ASM_ELF_NOTE_END + +BUILD_SALT
Signature · 1 line
2.17.1
PATCH v6 4/4 arm64: Add build salt to the vDSO
In reply to Laura AbbottThe vDSO needs to have a unique build id in a similar manner to the kernel and modules. Use the build salt macro.
---
v6: Remove the semi-colon, Ack from Will
--- arch/arm64/kernel/vdso/note.S | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kernel/vdso/note.S +3 -0
@@ -22,7 +22,10 @@ #include <linux/uts.h> #include <linux/version.h> #include <linux/elfnote.h> +#include <linux/build-salt.h> ELFNOTE_START(Linux, 0, "a") .long LINUX_VERSION_CODE ELFNOTE_END + +BUILD_SALT
Signature · 1 line
2.17.1
2018-07-06 9:49 GMT+09:00 Laura Abbott <[email protected]>:
Quoted 4 lines
Hi,
This is v6 of the series to allow unique build ids. v6 is mostly minor fixups and Acks for this to go through the kbuild tree.
Applied to linux-kbuild. Thanks!
Quoted 27 lines
Thanks,
LauraLaura Abbott (4):
kbuild: Add build salt to the kernel and modules
x86: Add build salt to the vDSO
powerpc: Add build salt to the vDSO
arm64: Add build salt to the vDSOarch/arm64/kernel/vdso/note.S | 3 +++ arch/powerpc/kernel/vdso32/note.S | 3 +++ arch/x86/entry/vdso/vdso-note.S | 3 +++ arch/x86/entry/vdso/vdso32/note.S | 3 +++ include/linux/build-salt.h | 20 ++++++++++++++++++++ init/Kconfig | 9 +++++++++ init/version.c | 3 +++ scripts/mod/modpost.c | 3 +++ 8 files changed, 47 insertions(+) create mode 100644 include/linux/build-salt.h--
2.17.1--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards Masahiro Yamada