From: "H. Peter Anvin" <hpa@zytor.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Kees Cook <keescook@chromium.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PING][PATCH v3] x86: Use `get_random_u8' for kernel stack offset randomization
Date: Tue, 14 Feb 2023 12:43:10 -0800 [thread overview]
Message-ID: <DDFBF35E-D837-4CDC-8EF8-2CBF75C77901@zytor.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2302140447190.6368@angie.orcam.me.uk>
On February 13, 2023 8:54:53 PM PST, "Maciej W. Rozycki" <macro@orcam.me.uk> wrote:
>On Mon, 13 Feb 2023, Thomas Gleixner wrote:
>
>> >> For x86 kernel stack offset randomization uses the RDTSC instruction,
>> >> which according to H. Peter Anvin is not a secure source of entropy:
>> >>
>> >> "RDTSC isn't a super fast instruction either, but what is *way* more
>> >> significant is that this use of RDTSC is NOT safe: in certain power states
>> >> it may very well be that stone number of lower bits of TSC contain no
>> >> entropy at all."
>> >
>> > Ping for:
>> > <https://lore.kernel.org/all/alpine.DEB.2.21.2301302011150.55843@angie.orcam.me.uk/>.
>>
>> I'm waiting for you to address Peter Anvins feedback.
>
> Do you mean this part:
>
>On Tue, 31 Jan 2023, H. Peter Anvin wrote:
>
>> Well, what I said was that masking out the low bits of TSC is not a valid use to
>> extract a random(-ish) number this way, because the lower bits may be affected
>> by quantization. Something like a circular multiply using a large prime with a
>> good 0:1 balance can be used to mitigate that.
>>
>> However, the second part is that subsequent RDTSCs will be highly correlated,
>> and so a CSPRNG is needed if you are actually trying to get reasonable security
>> this way – and, well, we already have one of those.
>
>? Well, I inferred, perhaps incorrectly, from the second paragraph that
>Peter agrees with my approach (with the CSPRNG being what `get_random_u8'
>and friends get at).
>
>> You also cite him
>> w/o providing a link to the conversation, so any context is missing.
>
> Sorry about that. I put the change heading for the previous iterations
>in the change log, but I agree actual web links would've been better:
><https://lore.kernel.org/all/alpine.DEB.2.21.2301081919550.65308@angie.orcam.me.uk/>,
><https://lore.kernel.org/all/alpine.DEB.2.21.2301082113350.65308@angie.orcam.me.uk/>.
>
> Please let me know if you need anything else. Thank you for your review.
>
> Maciej
No, I do indeed agree. We're talking something that is a part of an operation that is already fairly expensive. Now, if RDRAND is available on the hardware then that could be used if someone really wants it to go faster... but get_random_*() seems saner than doing ad hoc hacks.
next prev parent reply other threads:[~2023-02-14 20:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 21:30 [PATCH " Maciej W. Rozycki
2023-01-31 19:34 ` Jason A. Donenfeld
2023-01-31 20:52 ` H. Peter Anvin
2023-01-31 21:01 ` Miko Larsson
2023-02-12 23:17 ` [PING][PATCH " Maciej W. Rozycki
2023-02-13 19:01 ` Thomas Gleixner
2023-02-14 4:54 ` Maciej W. Rozycki
2023-02-14 20:43 ` H. Peter Anvin [this message]
2023-02-22 16:44 ` Jason A. Donenfeld
2023-02-13 19:03 ` [PATCH " Thomas Gleixner
2023-02-14 5:12 ` Maciej W. Rozycki
2023-02-14 13:39 ` Jason A. Donenfeld
2023-02-22 12:05 ` Maciej W. Rozycki
2023-06-05 15:45 ` Maciej W. Rozycki
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=DDFBF35E-D837-4CDC-8EF8-2CBF75C77901@zytor.com \
--to=hpa@zytor.com \
--cc=Jason@zx2c4.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mingo@redhat.com \
--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
all inboxes | Powered by JetHome®