Re: [PATCH] of/kexec: Omit kaslr-seed when kexecing with nokaslr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 8, 2023 at 5:45 AM Song Shuai <songshuaishuai@xxxxxxxxxxx> 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@xxxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux