Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9afb719e authored by Laura Abbott's avatar Laura Abbott Committed by Masahiro Yamada
Browse files

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.

Suggested-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 934193a6
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
#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 */
+9 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,15 @@ config LOCALVERSION_AUTO


	  which is done within the script "scripts/setlocalversion".)
	  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
config HAVE_KERNEL_GZIP
	bool
	bool


+3 −0
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
 */
 */


#include <generated/compile.h>
#include <generated/compile.h>
#include <linux/build-salt.h>
#include <linux/export.h>
#include <linux/export.h>
#include <linux/uts.h>
#include <linux/uts.h>
#include <linux/utsname.h>
#include <linux/utsname.h>
@@ -49,3 +50,5 @@ const char linux_proc_banner[] =
	"%s version %s"
	"%s version %s"
	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
	" (" LINUX_COMPILER ") %s\n";
	" (" LINUX_COMPILER ") %s\n";

BUILD_SALT;
+3 −0
Original line number Original line Diff line number Diff line
@@ -2125,10 +2125,13 @@ static int check_modname_len(struct module *mod)
 **/
 **/
static void add_header(struct buffer *b, 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/module.h>\n");
	buf_printf(b, "#include <linux/vermagic.h>\n");
	buf_printf(b, "#include <linux/vermagic.h>\n");
	buf_printf(b, "#include <linux/compiler.h>\n");
	buf_printf(b, "#include <linux/compiler.h>\n");
	buf_printf(b, "\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(vermagic, VERMAGIC_STRING);\n");
	buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
	buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
	buf_printf(b, "\n");
	buf_printf(b, "\n");