From patchwork Fri Jul 6 00:49:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10510479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD75660532 for ; Fri, 6 Jul 2018 00:50:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E6DA28346 for ; Fri, 6 Jul 2018 00:50:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 928D02834A; Fri, 6 Jul 2018 00:50:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A04C2810E for ; Fri, 6 Jul 2018 00:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FkwsguKOF60fTzw13Au6Va6JNP/NMPiyHpRI2ROqOYY=; b=eNIJ3ovkOTXmyfbJ+ODFccEDyf ONjzH7oN9W2GmIKhjB15MSlCkYp0lP40nm3kzXOgtrlaEqdiwPxNJNMrz8WdF5WP9psROq05xsQgQ Kn0H9+ZffMbqlFxlperayOUiu2xeaiv5J3lkXW+8ME1snIgMK1Za+qNjJEB7AqDX8x4UWg+3CsyEL I4FbHrOCkHNwEIHxF3NlActHdgCpsNDvVjJgAFB5tPxNY4AKxVl2z1OkRLCWbyb8NNEUMpH3Vsaic xd5TCOm5aWDQb6NkGbBzRrZAvHPaF46mA62n1iRrudbmWl0DxbnX/tzBijo6cbwgWKTdK6KQnskt+ supmLodg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbEx8-00075a-6J; Fri, 06 Jul 2018 00:50:26 +0000 Received: from mail-qt0-f195.google.com ([209.85.216.195]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbEwh-0006Eg-Uv for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 00:50:03 +0000 Received: by mail-qt0-f195.google.com with SMTP id f18-v6so8706836qtp.10 for ; Thu, 05 Jul 2018 17:49:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9/3S/vPBOZS1zms2ZTLLj6WKkzEDN0Zg6ke7GEjcPBY=; b=pek+EFVVS8cRaZGbjkgLr95fM8GAgFJWkFQ5scN/Q2ELWxJ2zv9FmxNFm6Ytu4s3LM rBWve5z3I9QLagZPQxLnrYofM05Buw/u7qarPmjkh6hDjYdbVQ8ROv3KL5HTVNsdRJyZ BTClaL0CZceJg33xL5KITOXw3LwL4gU3yN3R8eh0J0vo7sDQfh/kR0nKpp7Mdt3mWuC3 ViKb1P7v6UlaNwPHuAlv4cksNitQ8hciCLPtCBZCppoB1lXPGtgqxXImQ6VZDCRoYPeR tH0hkVbVweCW/+BGE4EAk1YWVrbGIkdKaCKbcRWh62paeQh5Js/SXg+YcJ2pKiWtEd2p acLQ== X-Gm-Message-State: APt69E2y49IObNaY9AN3s+nBKhuar6Gt0emb3fGMqcg7viQXOT0AdWVt VDumqI0D8T6MC/7LzvkBeUQaTA== X-Google-Smtp-Source: AAOMgpfskgVpIDN7evcrY3+vEsYJcz6P/GjCsVGJT3xLCLbbMVrgf2U7JYjB9i+XbRj/k99f/e/Klw== X-Received: by 2002:a0c:87e5:: with SMTP id 34-v6mr6888001qvk.30.1530838188933; Thu, 05 Jul 2018 17:49:48 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::f0c1]) by smtp.gmail.com with ESMTPSA id q67-v6sm4675205qkb.16.2018.07.05.17.49.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jul 2018 17:49:47 -0700 (PDT) From: Laura Abbott To: Andy Lutomirski , mjw@fedoraproject.org, "H . J . Lu" , Masahiro Yamada , Michael Ellerman , Catalin Marinas , Will Deacon Subject: [PATCHv6 1/4] kbuild: Add build salt to the kernel and modules Date: Thu, 5 Jul 2018 17:49:37 -0700 Message-Id: <20180706004940.32587-2-labbott@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180706004940.32587-1-labbott@redhat.com> References: <20180706004940.32587-1-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180705_175000_191540_7C846D36 X-CRM114-Status: GOOD ( 18.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Clifton , linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, X86 ML , linux-kernel@vger.kernel.org, Cary Coutant , Laura Abbott , Linus Torvalds , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Masahiro Yamada Signed-off-by: Laura Abbott --- 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 diff --git a/include/linux/build-salt.h b/include/linux/build-salt.h new file mode 100644 index 000000000000..bb007bd05e7a --- /dev/null +++ b/include/linux/build-salt.h @@ -0,0 +1,20 @@ +#ifndef __BUILD_SALT_H +#define __BUILD_SALT_H + +#include + +#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 */ diff --git a/init/Kconfig b/init/Kconfig index 041f3a022122..d39b31484c52 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -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 diff --git a/init/version.c b/init/version.c index bfb4e3f4955e..ef4012ec4375 100644 --- a/init/version.c +++ b/init/version.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -49,3 +50,5 @@ const char linux_proc_banner[] = "%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" " (" LINUX_COMPILER ") %s\n"; + +BUILD_SALT; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1663fb19343a..dc6d714e4dcb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -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 \n"); buf_printf(b, "#include \n"); buf_printf(b, "#include \n"); buf_printf(b, "#include \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");