From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
linux-crypto@vger.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 v5 2/3] random: introduce generic vDSO getrandom() implementation
Date: Mon, 21 Nov 2022 04:23:20 +0100 [thread overview]
Message-ID: <Y3rvKEeSAq6548Sz@zx2c4.com> (raw)
In-Reply-To: <Y3l9MXCO02/rOpFx@zx2c4.com>
On Sun, Nov 20, 2022 at 02:04:49AM +0100, Jason A. Donenfeld wrote:
> On Sun, Nov 20, 2022 at 01:53:53AM +0100, Jason A. Donenfeld wrote:
> > I'm not quite sure what the best approach here is. One idea would be to
> > just note that libcs should wait until vgetrandom() has returned
> > everywhere before forking, using its atfork functionality.
>
> To elaborate on this idea a bit, the way this looks is:
>
> rwlock_t l;
> pid_t fork(void)
> {
> pid_t pid;
> write_lock(&l);
> pid = syscall_fork();
> write_unlock(&l);
> return pid;
> }
> ssize_t getrandom(...)
> {
> ssize_t ret;
> ...
> if (!read_try_lock(&l))
> return syscall_getrandom(...);
> ret = vdso_getrandom(...);
> read_unlock(&l);
> return ret;
> }
>
> So maybe that doesn't seem that bad, especially considering libc already
> has the kind of infrastructure in place to do that somewhat easily.
> Maybe there's a priority locking thing to get right here -- the writer
> should immediately starve out all future readers, so it's not unbound --
> but that seems par for the course.
Fortunately none of this was necessary, and I've got things implemented
without needing to resort to that, for v+1.
Jason
next prev parent reply other threads:[~2022-11-21 3:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-19 12:09 [PATCH v5 0/3] implement getrandom() in vDSO Jason A. Donenfeld
2022-11-19 12:09 ` [PATCH v5 1/3] random: add vgetrandom_alloc() syscall Jason A. Donenfeld
2022-11-19 20:39 ` Eric Biggers
2022-11-19 23:59 ` Jason A. Donenfeld
2022-11-20 1:40 ` Eric Biggers
2022-11-20 1:45 ` Jason A. Donenfeld
2022-11-19 12:09 ` [PATCH v5 2/3] random: introduce generic vDSO getrandom() implementation Jason A. Donenfeld
2022-11-19 23:10 ` Eric Biggers
2022-11-20 0:53 ` Jason A. Donenfeld
2022-11-20 1:04 ` Jason A. Donenfeld
2022-11-21 3:23 ` Jason A. Donenfeld [this message]
2022-11-20 1:43 ` Jason A. Donenfeld
2022-11-21 3:22 ` Jason A. Donenfeld
2022-11-20 1:51 ` Eric Biggers
2022-11-19 12:09 ` [PATCH v5 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=Y3rvKEeSAq6548Sz@zx2c4.com \
--to=jason@zx2c4.com \
--cc=adhemerval.zanella@linaro.org \
--cc=carlos@redhat.com \
--cc=ebiggers@kernel.org \
--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