From: Borislav Petkov <bp@suse.de>
To: speck@linutronix.de
Subject: [MODERATED] Additional sampling fun
Date: Fri, 28 Feb 2020 17:21:40 +0100 [thread overview]
Message-ID: <20200228162140.GB24511@zn.tnic> (raw)
In-Reply-To: <20200220081420.GA3328448@kroah.com>
On Thu, Feb 20, 2020 at 09:14:20AM +0100, speck for Greg KH wrote:
> Then we need to stop using RDRAND internally for our "give me a random
> number api" which has spread to more and more parts of the kernel.
>
> Here's a patch that does so:
> https://lore.kernel.org/lkml/20200216161836.1976-1-Jason@zx2c4.com/
> which I'm going to advise get merged now and backported to the stable
> branches.
So one of our guys - Nicolai Stange - was looking at this
wrt backporting it to trees and there's another problem in
add_interrupt_randomness() which could potentially turn out
to be nasty.
We asked him to write it up for speck@ (he's not subscribed) so that we
can discuss it here first. Here is the deal in his own words:
"In the context of the get_random_long() patch posted at [1], I noticed
that there's also a RDSEED insn issued from the interrupt path, which
perhaps might have undesired effects performance-wise.
More specifically, add_interrupt_randomness() would issue one RDSEED
either once a second or every 64 interrupts, whichever comes first:
void add_interrupt_randomness(int irq, int irq_flags)
{
fast_mix(fast_pool); /* increments fast_pool->count */
...
if ((fast_pool->count < 64) &&
!time_after(now, fast_pool->last + HZ))
return;
...
fast_pool->last = now;
if (arch_get_random_seed_long(&seed)) {}
...
}
So while this certainly won't matter much on average, I'm still
wondering whether or not this RDSEED could potentially cause IRQ
latency spikes relevant e.g. to -RT and/or under high IRQ load?
FWIW, the commit introducing the arch_get_random_seed_long() invocation
to add_interrupt_randomness() was commit 83664a6928a4 ("random: Use
arch_get_random_seed*() at init time and once a second").
I can only guess, but I think the motivation for mixing
arch_get_random_seed_long() from the interrupt path was probably to
sync that with the IRQ rate. That is, to make sure that the entropy
mixed from RDSEED doesn't dominate the interrupt entropy source.
[1] https://lkml.kernel.org/r/20200216161836.1976-1-Jason@zx2c4.com
"
Thx.
--
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
--
next prev parent reply other threads:[~2020-02-28 16:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 22:45 [MODERATED] [PATCH 0/2] more sampling fun 0 mark gross
2020-02-20 1:53 ` [MODERATED] " mark gross
2020-02-20 8:14 ` Greg KH
2020-02-20 14:27 ` Greg KH
2020-02-20 15:40 ` mark gross
2020-02-20 16:18 ` Greg KH
2020-02-20 14:55 ` Andi Kleen
2020-02-20 15:05 ` Greg KH
2020-02-20 16:55 ` Andi Kleen
2020-02-20 21:51 ` Josh Poimboeuf
2020-02-20 22:15 ` Andi Kleen
2020-02-20 22:59 ` Kees Cook
2020-02-20 15:09 ` mark gross
2020-02-28 16:21 ` Borislav Petkov [this message]
2020-02-28 16:34 ` [MODERATED] Re: Additional sampling fun Greg KH
2020-02-28 17:38 ` mark gross
2020-02-28 17:44 ` Thomas Gleixner
2020-02-28 18:09 ` [MODERATED] " Luck, Tony
2020-02-28 18:40 ` Borislav Petkov
2020-02-28 21:53 ` Thomas Gleixner
2020-03-03 1:03 ` [MODERATED] " Luck, Tony
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=20200228162140.GB24511@zn.tnic \
--to=bp@suse.de \
--cc=speck@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).