[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2571f72a-3420-977f-7b08-8f6216bba6a8@csgroup.eu>
Date: Sat, 19 Nov 2022 07:51:21 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: "Jason A. Donenfeld" <Jason@...c4.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"patches@...ts.linux.dev" <patches@...ts.linux.dev>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Adhemerval Zanella Netto <adhemerval.zanella@...aro.org>,
Carlos O'Donell <carlos@...hat.com>
Subject: Re: [PATCH v4 2/3] random: introduce generic vDSO getrandom()
implementation
Le 19/11/2022 à 01:04, Jason A. Donenfeld a écrit :
> On Sat, Nov 19, 2022 at 12:55:02AM +0100, Jason A. Donenfeld wrote:
>> Sorry if I'm a bit slow here to grok what's up.
Maybe I should also have mentionned commit ce7d8056e38b ("powerpc/vdso:
Prepare for switching VDSO to generic C implementation.") for you to
have a complete picture.
>
> Okay, I think I see it now. That's a complicated patch for a simple idea
> because gettime is more complicated than getrandom. I suspect what you
> want is something like the below, correct? Seems easy enough.
Yes it is exactly that, powerpc will then call __cvdso_getrandom_data()
directly and pass rng_info pointer.
>
> diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c
> index b253e9247706..b3282d7cfb53 100644
> --- a/lib/vdso/getrandom.c
> +++ b/lib/vdso/getrandom.c
> @@ -41,10 +41,10 @@ static void memcpy_and_zero(void *dst, void *src, size_t len)
> }
>
> static __always_inline ssize_t
> -__cvdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state)
> +__cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_t len,
> + unsigned int flags, void *opaque_state)
> {
> struct vgetrandom_state *state = opaque_state;
> - const struct vdso_rng_data *rng_info = __arch_get_vdso_rng_data();
> u32 chacha_state[CHACHA_STATE_WORDS];
> ssize_t ret = min_t(size_t, MAX_RW_COUNT, len);
> unsigned long current_generation;
> @@ -107,3 +107,9 @@ __cvdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_sta
> memzero_explicit(chacha_state, sizeof(chacha_state));
> goto more_batch;
> }
> +
> +static __always_inline ssize_t
> +__cvdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state)
> +{
> + return __cvdso_getrandom_data(__arch_get_vdso_rng_data(), buffer, len, flags, opaque_state);
> +}
>
Powered by blists - more mailing lists