devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh+dt@kernel.org>
To: Song Shuai <songshuaishuai@tinylab.org>
Cc: frowand.list@gmail.com, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] of/kexec: Omit kaslr-seed when kexecing with nokaslr
Date: Fri, 8 Sep 2023 09:58:02 -0500	[thread overview]
Message-ID: <CAL_JsqJFWTWg9gmO7P8d5-W9VeMtmazhCsQW121LDAWLMAHEnQ@mail.gmail.com> (raw)
In-Reply-To: <20230908104458.775740-1-songshuaishuai@tinylab.org>

On Fri, Sep 8, 2023 at 5:45 AM Song Shuai <songshuaishuai@tinylab.org> wrote:
>
> The chosen node always adds the kaslr-seed property which is needless
> for the kernels kexeced with the cmdline contained "nokaslr".
>
> So omit the kaslr-seed when kexecing with nokaslr.

The kexec'ed kernel can ignore bootargs with CONFIG_CMDLINE_FORCE. So
you don't know if kaslr-seed will be used or not.

> Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> ---
>  drivers/of/kexec.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
> index f26d2ba8a371..c0d53b10cb70 100644
> --- a/drivers/of/kexec.c
> +++ b/drivers/of/kexec.c
> @@ -19,6 +19,7 @@
>  #include <linux/random.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
> +#include <linux/string.h>
>
>  #define RNG_SEED_SIZE          128
>
> @@ -263,6 +264,14 @@ static inline int setup_ima_buffer(const struct kimage *image, void *fdt,
>  }
>  #endif /* CONFIG_IMA_KEXEC */
>
> +static bool is_nokaslr_cmdline(const char *cmdline)
> +{
> +       char *str;
> +
> +       str = strstr(cmdline, "nokaslr");
> +       return str == cmdline || (str > cmdline && *(str - 1) == ' ');

Yet another copy of the same code. That's a clue to refactor into a
common function.

Rob

  reply	other threads:[~2023-09-08 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:44 [PATCH] of/kexec: Omit kaslr-seed when kexecing with nokaslr Song Shuai
2023-09-08 14:58 ` Rob Herring [this message]
2023-09-11  2:22   ` Song Shuai

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=CAL_JsqJFWTWg9gmO7P8d5-W9VeMtmazhCsQW121LDAWLMAHEnQ@mail.gmail.com \
    --to=robh+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=songshuaishuai@tinylab.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).