From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"patches@lists.linux.dev" <patches@lists.linux.dev>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
Carlos O'Donell <carlos@redhat.com>
Subject: Re: [PATCH v4 2/3] random: introduce generic vDSO getrandom() implementation
Date: Sat, 19 Nov 2022 01:04:35 +0100 [thread overview]
Message-ID: <Y3gdkxq4FjXcmAwA@zx2c4.com> (raw)
In-Reply-To: <Y3gbVorxZyb4SBJa@zx2c4.com>
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.
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.
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);
+}
next prev parent reply other threads:[~2022-11-19 0:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 17:28 [PATCH v4 0/3] implement getrandom() in vDSO Jason A. Donenfeld
2022-11-18 17:28 ` [PATCH v4 1/3] random: add vgetrandom_alloc() syscall Jason A. Donenfeld
2022-11-19 0:20 ` Jason A. Donenfeld
2022-11-18 17:28 ` [PATCH v4 2/3] random: introduce generic vDSO getrandom() implementation Jason A. Donenfeld
2022-11-18 19:34 ` Christophe Leroy
2022-11-18 23:55 ` Jason A. Donenfeld
2022-11-19 0:04 ` Jason A. Donenfeld [this message]
2022-11-19 7:51 ` Christophe Leroy
2022-11-19 11:43 ` Jason A. Donenfeld
2022-11-19 12:12 ` Jason A. Donenfeld
2022-11-18 17:28 ` [PATCH v4 3/3] x86: vdso: Wire up getrandom() vDSO implementation Jason A. Donenfeld
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=Y3gdkxq4FjXcmAwA@zx2c4.com \
--to=jason@zx2c4.com \
--cc=adhemerval.zanella@linaro.org \
--cc=carlos@redhat.com \
--cc=christophe.leroy@csgroup.eu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox