[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHmME9owdbHzfb66xisoWmvWeT_-hkxCu7tR2=Rbye_ik1JgQQ@mail.gmail.com>
Date: Fri, 9 Feb 2024 20:53:07 +0100
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: "Reshetova, Elena" <elena.reshetova@...el.com>, "Theodore Ts'o" <tytso@....edu>,
Dave Hansen <dave.hansen@...ux.intel.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, "H. Peter Anvin" <hpa@...or.com>,
"x86@...nel.org" <x86@...nel.org>,
Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Nakajima, Jun" <jun.nakajima@...el.com>, Tom Lendacky <thomas.lendacky@....com>,
"Kalra, Ashish" <ashish.kalra@....com>, Sean Christopherson <seanjc@...gle.com>,
"linux-coco@...ts.linux.dev" <linux-coco@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] x86/random: Retry on RDSEED failure
Hi Kirill,
On Sat, Feb 3, 2024 at 11:12 AM Jason A. Donenfeld <Jason@...c4.com> wrote:
> Yea, actually, I had a pretty similar idea for something like that
> that's very non-invasive, where none of this even touches the RDRAND
> core code, much less random.c. Specifically, we consider "adding some
> extra RDRAND to the pool" like any other driver that wants to add some
> of its own seeds to the pool, with add_device_randomness(), a call that
> lives in various driver code, doesn't influence any entropy readiness
> aspects of random.c, and can safely be sprinkled in any device or
> platform driver.
>
> Specifically what I'm thinking about is something like:
>
> void coco_main_boottime_init_function_somewhere_deep_in_arch_code(void)
> {
> // [...]
> // bring up primary CoCo nuts
> // [...]
>
> /* CoCo requires an explicit RDRAND seed, because the host can make the
> * rest of the system deterministic.
> */
> unsigned long seed[32 / sizeof(long)];
> size_t i, longs;
> for (i = 0; i < ARRAY_SIZE(seed); i += longs) {
> longs = arch_get_random_longs(&seed[i], ARRAY_SIZE(seed) - i);
> /* If RDRAND is being DoS'd, panic, because we can't ensure
> * confidentiality.
> */
> BUG_ON(!longs);
> }
> add_device_randomness(seed, sizeof(seed));
> memzero_explicit(seed, sizeof(seed));
>
> // [...]
> // do other CoCo things
> // [...]
> }
>
> I would have no objection to the CoCo people adding something like this
> and would give it my Ack, but more importantly, my Ack for that doesn't
> even matter, because add_device_randomness() is pretty innocuous.
>
> So Kirill, if nobody else here objects to that approach, and you want to
> implement it in some super minimal way like that, that would be fine
> with me. Or maybe we want to wait for that internal inquiry at Intel to
> return some answers first. But either way, this might be an easy
> approach that doesn't add too much complexity.
I went ahead and implemented this just to have something concrete out there:
https://lore.kernel.org/all/20240209164946.4164052-1-Jason@zx2c4.com/
I probably screwed up some x86 platform conventions/details, but
that's the general idea I had in mind.
Jason
Powered by blists - more mailing lists