From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Will Deacon <will@kernel.org>,
Julien Thierry <julien.thierry.kdev@gmail.com>,
kvm@vger.kernel.org, Alexandru Elisei <alexandru.elisei@arm.com>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: Re: [PATCH kvmtool 0/2] Fix virtio/rng handling in low entropy situations
Date: Wed, 19 Apr 2023 16:10:13 +0100 [thread overview]
Message-ID: <20230419151013.GC94027@myrica> (raw)
In-Reply-To: <20230419135832.GB94027@myrica>
On Wed, Apr 19, 2023 at 02:58:32PM +0100, Jean-Philippe Brucker wrote:
> On Thu, Apr 13, 2023 at 05:57:55PM +0100, Andre Przywara wrote:
> > I am not sure we now really need patch 2 anymore (originally I had this
> > one before I switched to /dev/urandom). I *think* even a read from
> > /dev/urandom can return early (because of a signal, for instance), so
> > a return with 0 bytes read seems possible.
>
> Given that this should be very rare, maybe a simple loop would be better
> than switching the blocking mode? It's certainly a good idea to apply the
> "MUST" requirements from virtio.
Digging a bit more, the manpage [1] is helpful:
The O_NONBLOCK flag has no effect when opening /dev/urandom.
When calling read(2) for the device /dev/urandom, reads of up to
256 bytes will return as many bytes as are requested and will not
be interrupted by a signal handler. Reads with a buffer over
this limit may return less than the requested number of bytes or
fail with the error EINTR, if interrupted by a signal handler.
So I guess you can also drop the O_NONBLOCK flag in patch 1. And for the
second one, maybe we could fallback to a 256 bytes read if the first one
fails
Thanks,
Jean
[1] https://man7.org/linux/man-pages/man4/urandom.4.html
next prev parent reply other threads:[~2023-04-19 15:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 16:57 [PATCH kvmtool 0/2] Fix virtio/rng handling in low entropy situations Andre Przywara
2023-04-13 16:57 ` [PATCH kvmtool 1/2] virtio/rng: switch to using /dev/urandom Andre Przywara
2023-04-19 13:53 ` Jean-Philippe Brucker
2023-04-13 16:57 ` [RFC PATCH kvmtool 2/2] virtio/rng: return at least one byte of entropy Andre Przywara
2023-04-19 13:58 ` [PATCH kvmtool 0/2] Fix virtio/rng handling in low entropy situations Jean-Philippe Brucker
2023-04-19 15:10 ` Jean-Philippe Brucker [this message]
2023-04-19 15:31 ` Andre Przywara
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=20230419151013.GC94027@myrica \
--to=jean-philippe@linaro.org \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=sami.mujawar@arm.com \
--cc=will@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