From: Mark Rutland <mark.rutland@arm.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: devicetree@vger.kernel.org, Yu Zhao <yuzhao@google.com>,
Kees Cook <keescook@chromium.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Stephen Boyd <swboyd@chromium.org>,
Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>,
Jun Yao <yaojun8558363@gmail.com>,
Miles Chen <miles.chen@mediatek.com>,
Rob Herring <robh+dt@kernel.org>,
James Morse <james.morse@arm.com>,
Andrew Murray <andrew.murray@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Laura Abbott <labbott@redhat.com>,
Frank Rowand <frowand.list@gmail.com>,
linux-arm-kernel@lists.infradead.org,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH v6 3/3] arm64: kexec_file: add rng-seed support
Date: Fri, 28 Jun 2019 10:42:51 +0100 [thread overview]
Message-ID: <20190628094251.GC36437@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20190612043258.166048-4-hsinyi@chromium.org>
On Wed, Jun 12, 2019 at 12:33:02PM +0800, Hsin-Yi Wang wrote:
> Adding "rng-seed" to dtb. It's fine to add this property if original
> fdt doesn't contain it. Since original seed will be wiped after
> read, so use a default size 128 bytes here.
Why is 128 bytes the default value?
I didn't see an update to Documentation/devicetree/bindings/chosen.txt,
so it's not clear to me precisely what we expect.
>
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> ---
> change log v5->v6:
> * no change
> ---
> arch/arm64/kernel/machine_kexec_file.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
> index 58871333737a..d40fde72a023 100644
> --- a/arch/arm64/kernel/machine_kexec_file.c
> +++ b/arch/arm64/kernel/machine_kexec_file.c
> @@ -27,6 +27,8 @@
> #define FDT_PROP_INITRD_END "linux,initrd-end"
> #define FDT_PROP_BOOTARGS "bootargs"
> #define FDT_PROP_KASLR_SEED "kaslr-seed"
> +#define FDT_PROP_RNG_SEED "rng-seed"
> +#define RNG_SEED_SIZE 128
>
> const struct kexec_file_ops * const kexec_file_loaders[] = {
> &kexec_image_ops,
> @@ -102,6 +104,23 @@ static int setup_dtb(struct kimage *image,
> FDT_PROP_KASLR_SEED);
> }
>
> + /* add rng-seed */
> + if (rng_is_initialized()) {
> + void *rng_seed = kmalloc(RNG_SEED_SIZE, GFP_ATOMIC);
For 128 bytes, it would be better to use a buffer on the stack. That
avoids the possibility of the allocation failing.
> + get_random_bytes(rng_seed, RNG_SEED_SIZE);
> +
> + ret = fdt_setprop(dtb, off, FDT_PROP_RNG_SEED, rng_seed,
> + RNG_SEED_SIZE);
> + kfree(rng_seed);
> +
> + if (ret)
> + goto out;
If the RNG wasn't initialised, we'd carry on with a warning. Why do we
follow a different policy here?
Thanks,
Mark.
> +
> + } else {
> + pr_notice("RNG is not initialised: omitting \"%s\" property\n",
> + FDT_PROP_RNG_SEED);
> + }
> +
> out:
> if (ret)
> return (ret == -FDT_ERR_NOSPACE) ? -ENOMEM : -EINVAL;
> @@ -110,7 +129,8 @@ static int setup_dtb(struct kimage *image,
> }
>
> /*
> - * More space needed so that we can add initrd, bootargs and kaslr-seed.
> + * More space needed so that we can add initrd, bootargs, kaslr-seed, and
> + * rng-seed.
> */
> #define DTB_EXTRA_SPACE 0x1000
>
> --
> 2.20.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-06-28 9:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-12 4:32 [PATCH v6 0/3] add support for rng-seed Hsin-Yi Wang
2019-06-12 4:32 ` [PATCH v6 1/3] arm64: map FDT as RW for early_init_dt_scan() Hsin-Yi Wang
2019-06-13 11:44 ` Mike Rapoport
2019-06-12 4:33 ` [PATCH v6 2/3] fdt: add support for rng-seed Hsin-Yi Wang
2019-06-12 17:02 ` Rob Herring
2019-06-28 9:35 ` Mark Rutland
2019-06-28 11:23 ` Hsin-Yi Wang
2019-06-12 4:33 ` [PATCH v6 3/3] arm64: kexec_file: add rng-seed support Hsin-Yi Wang
2019-06-28 9:42 ` Mark Rutland [this message]
2019-06-28 11:47 ` Hsin-Yi Wang
2019-07-01 4:33 ` Hsin-Yi Wang
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=20190628094251.GC36437@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.murray@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=hsinyi@chromium.org \
--cc=james.morse@arm.com \
--cc=keescook@chromium.org \
--cc=labbott@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miles.chen@mediatek.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rppt@linux.ibm.com \
--cc=swboyd@chromium.org \
--cc=will.deacon@arm.com \
--cc=yaojun8558363@gmail.com \
--cc=yuzhao@google.com \
/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