From: George Spelvin <lkml@SDF.ORG>
To: Willy Tarreau <w@1wt.eu>
Cc: netdev@vger.kernel.org, aksecurity@gmail.com,
torvalds@linux-foundation.org, edumazet@google.com,
Jason@zx2c4.com, luto@kernel.org, keescook@chromium.org,
tglx@linutronix.de, peterz@infradead.org, tytso@mit.edu,
lkml.mplumb@gmail.com, stephen@networkplumber.org, fw@strlen.de,
George Spelvin <lkml@SDF.ORG>
Subject: Re: [DRAFT PATCH] random32: make prandom_u32() output unpredictable
Date: Sun, 9 Aug 2020 18:30:17 +0000 [thread overview]
Message-ID: <20200809183017.GC25124@SDF.ORG> (raw)
In-Reply-To: <20200809173302.GA8027@1wt.eu>
On Sun, Aug 09, 2020 at 07:33:03PM +0200, Willy Tarreau wrote:
> Not that low in fact because they don't know precisely when the call is
> made. I mean, let's say we're in the worst case, with two VMs running on
> two siblings of the same core, with the same TSC, on a 3 GHz machine. The
> attacker can stress the victim at 100k probes per second. That's still
> 15 bits of uncertainty on the TSC value estimation which is added to each
> call. Even on the first call this is enough to make a source port
> unguessable, and preventing the attacker from staying synchronized with
> its victim. And I'm only speaking about an idle remote machine, not even
> one taking unobservable traffic, which further adds to the difficulty.
I'm trying to understand your attack scenario. I'm assuming that an
attacker can call prandom_u32() locally. (I don't have a specific code
path, but given the number of uses in the kernel, I assume *one* of
them will leak the output directly.) And repeat the call fast
enough that there's at most *one* other user between our calls.
If an attacker knows the initial state, does an rdtsc, prandom_u32(),
and a second rdtsc, then they can guess the TSC value used in than
prandom_u32() quite accurately (4-6 bits fuzz, perhaps). This is
trivial to brute force.
The fun comes if someone else does a prandom_u32() call in between.
All of a sudden, the 4-6 bit brute force of one get_cycles() value
fails to find a solution. Someone else has called prandom_u32()!
Now we have 15 bits of uncertainty about that other call, and 5 bits
of uncertainty about our call. 2^20 possibilities only takes a few
milliseconds to test, and the 32-bit output of prandom_u32() can
verify a guess with minimal probability of error.
(Note that, to maintain tracking, we have to keep hammering
prandom_u32() *during* the search, but we can just buffer the results
and process them after the expensive search is complete.)
What you can see here is the incredible power of *multiple* unobserved
seedings. As long as an attacker can limit things to one unobserved
prandom_u32(), it's a simple brute force.
If there are mroe than one, the additional bits of uncertainty
quickly make things impractical.
This is why I'm so keen on less frequent, more catastrophic,
reseeding. Yes, the delay means an attacker who has captured
the state retains full knowledge for longer. But they get
kicked off as soon as the catastophe happens. Without it, they
can keep tracking the state indefinitely.
Even something simple like buffering 8 TSC samples, and adding them
at 32-bit offsets across the state every 8th call, would make a huge
difference.
Even if 7 of the timestamps are from attacker calls (4 bits
uncertainty), the time of the target call is 8x less known
(so it goes from 15 to 18 bits), and the total becomes
46 bits. *So* much better.
> I can run some tests on this as
> well. I'd really need to try on a cleaner setup, I have remote machines
> at the office but I don't feel safe enough to remotely reboot them and
> risk to lose them :-/
Yeah, test kernels are nervous-making that way.
> I'll also test on arm/arm64 to make sure we don't introduce a significant
> cost there.
I don't expect a problem, but SipHash is optimized for 4-issue processors,
and on narrower machines fewer instructions are "free".
next prev parent reply other threads:[~2020-08-09 18:31 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-08 15:26 Flaw in "random32: update the net random state on interrupt and activity" George Spelvin
2020-08-08 17:07 ` Andy Lutomirski
2020-08-08 18:08 ` Willy Tarreau
2020-08-08 18:13 ` Linus Torvalds
2020-08-08 19:03 ` George Spelvin
2020-08-08 19:49 ` Andy Lutomirski
2020-08-08 21:29 ` George Spelvin
2020-08-08 17:44 ` Willy Tarreau
2020-08-08 18:19 ` Linus Torvalds
2020-08-08 18:53 ` Willy Tarreau
2020-08-08 20:47 ` George Spelvin
2020-08-08 20:52 ` Linus Torvalds
2020-08-08 22:27 ` George Spelvin
2020-08-09 2:07 ` Linus Torvalds
2020-08-11 16:01 ` Eric Dumazet
2020-08-08 19:18 ` Florian Westphal
2020-08-08 20:59 ` George Spelvin
2020-08-08 21:18 ` Willy Tarreau
2020-08-08 20:08 ` George Spelvin
2020-08-08 20:47 ` Linus Torvalds
2020-08-09 6:57 ` [DRAFT PATCH] random32: make prandom_u32() output unpredictable George Spelvin
2020-08-09 9:38 ` Willy Tarreau
2020-08-09 17:06 ` George Spelvin
2020-08-09 17:33 ` Willy Tarreau
2020-08-09 18:30 ` George Spelvin [this message]
2020-08-09 19:16 ` Willy Tarreau
2020-08-10 11:47 ` Willy Tarreau
2020-08-10 12:01 ` David Laight
2020-08-10 14:48 ` Willy Tarreau
2020-08-10 12:03 ` Florian Westphal
2020-08-10 14:53 ` Willy Tarreau
2020-08-10 16:31 ` Linus Torvalds
2020-08-10 16:58 ` Willy Tarreau
2020-08-10 17:45 ` Linus Torvalds
2020-08-10 18:01 ` Willy Tarreau
2020-08-10 21:04 ` Willy Tarreau
2020-08-11 5:26 ` George Spelvin
2020-08-11 5:37 ` Willy Tarreau
2020-08-11 3:47 ` George Spelvin
2020-08-11 3:58 ` Willy Tarreau
[not found] ` <fdbc7d7d-cba2-ef94-9bde-b3ccae0cfaac@gmail.com>
2020-08-09 21:10 ` Marc Plumb
2020-08-09 21:48 ` Linus Torvalds
2020-08-09 13:50 ` Randy Dunlap
[not found] ` <CANEQ_++a4YcwQQ2XhuguTono9=RxbSRVsMw08zLWBWJ_wxG2AQ@mail.gmail.com>
2020-08-09 16:08 ` George Spelvin
[not found] <CA+icZUVnsmf1kXPYFYufStQ_MxnLuxL+EWfDS2wQy1VbAEMwkA@mail.gmail.com>
2020-08-09 21:10 ` Sedat Dilek
[not found] ` <20200809235412.GD25124@SDF.ORG>
[not found] ` <20200810034948.GB8262@1wt.eu>
[not found] ` <20200811053455.GH25124@SDF.ORG>
[not found] ` <20200811054328.GD9456@1wt.eu>
[not found] ` <20200811062814.GI25124@SDF.ORG>
[not found] ` <20200811074538.GA9523@1wt.eu>
2020-08-11 10:51 ` Sedat Dilek
2020-08-11 11:01 ` Sedat Dilek
2020-08-12 3:21 ` Willy Tarreau
2020-08-13 7:53 ` Sedat Dilek
2020-08-13 8:06 ` Willy Tarreau
2020-08-13 8:13 ` Sedat Dilek
2020-08-13 8:27 ` Sedat Dilek
2020-08-13 14:00 ` Eric Dumazet
2020-08-13 16:02 ` Sedat Dilek
2020-08-14 15:32 ` Sedat Dilek
2020-08-14 16:05 ` Willy Tarreau
2020-08-14 16:17 ` Sedat Dilek
2020-08-16 15:01 ` Willy Tarreau
2020-08-16 16:48 ` Sedat Dilek
2020-08-20 3:05 ` Sedat Dilek
2020-08-20 4:33 ` Willy Tarreau
2020-08-20 4:42 ` Sedat Dilek
2020-08-20 6:08 ` Willy Tarreau
2020-08-20 6:58 ` Willy Tarreau
2020-08-20 8:05 ` Willy Tarreau
2020-08-20 12:08 ` Sedat Dilek
[not found] ` <CANEQ_+L+22Hkdqf38Zr0bfq16fcL1Ax2X9fToXV_niHKXCB8aA@mail.gmail.com>
2020-08-27 1:09 ` Willy Tarreau
2020-08-27 7:08 ` Sedat Dilek
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=20200809183017.GC25124@SDF.ORG \
--to=lkml@sdf.org \
--cc=Jason@zx2c4.com \
--cc=aksecurity@gmail.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=keescook@chromium.org \
--cc=lkml.mplumb@gmail.com \
--cc=luto@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=stephen@networkplumber.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
/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).