All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Jann Horn <jannh@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] x86/boot: avoid recompiling kaslr.c for incremental rebuilds
Date: Fri, 23 Feb 2024 15:52:00 -0800	[thread overview]
Message-ID: <202402231550.80B97C8E@keescook> (raw)
In-Reply-To: <20240220192144.2050167-4-jannh@google.com>

On Tue, Feb 20, 2024 at 08:21:44PM +0100, Jann Horn wrote:
> Currently, every kernel rebuild needs to compile kaslr.c again because
> UTS_VERSION changes on every rebuild.
> Move the build string into a separate object file to speed things up.
> 
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
>  arch/x86/boot/compressed/dynamic_vars.c |  8 ++++++++
>  arch/x86/boot/compressed/dynamic_vars.h |  3 +++
>  arch/x86/boot/compressed/kaslr.c        | 10 ++--------
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/dynamic_vars.c b/arch/x86/boot/compressed/dynamic_vars.c
> index cda64ff4b6da..15a57fbb05e3 100644
> --- a/arch/x86/boot/compressed/dynamic_vars.c
> +++ b/arch/x86/boot/compressed/dynamic_vars.c
> @@ -1,9 +1,17 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/const.h>
>  #include "dynamic_vars.h"
> +#include <generated/compile.h>
> +#include <generated/utsrelease.h>
> +#include <generated/utsversion.h>
>  #include "../voffset.h"
>  
>  const unsigned long vo__text = VO__text;
>  const unsigned long vo___bss_start = VO___bss_start;
>  const unsigned long vo__end = VO__end;
>  const unsigned long kernel_total_size = VO__end - VO__text;
> +
> +/* Simplified build-specific string for starting entropy. */
> +const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
> +		LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
> +unsigned long build_str_len = sizeof(build_str)-1;

This can be const too, yes? (Also, you didn't want to include the
trailing NUL in the xor?

Otherwise, yeah, I like this whole series.

-- 
Kees Cook

      parent reply	other threads:[~2024-02-23 23:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 19:21 [PATCH 0/3] avoid unnecessary recompilations in x86 boot code Jann Horn
2024-02-20 19:21 ` [PATCH 1/3] x86/boot: fix KASLR hashing to use full input Jann Horn
2024-02-20 19:21 ` [PATCH 2/3] x86/boot: avoid recompiling misc.c for incremental rebuilds Jann Horn
2024-02-20 19:21 ` [PATCH 3/3] x86/boot: avoid recompiling kaslr.c " Jann Horn
2024-02-20 19:34   ` Kees Cook
2024-02-23 23:52   ` Kees Cook [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202402231550.80B97C8E@keescook \
    --to=keescook@chromium.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.