rand_util_win.cc uses a deprecated MSDN method and doesn't work on brand new threads |
|||||
Issue description[8088:4640:0517/151649.162:FATAL:rand_util_win.cc(32)] Check failed: success. Backtrace: base::debug::StackTrace::StackTrace [0x03330E10+32] base::debug::StackTrace::StackTrace [0x032F58CD+13] logging::LogMessage::~LogMessage [0x032982C3+83] base::RandBytes [0x0330135C+76] base::RandDouble [0x032DA000+32] base::internal::ServiceThread::Init [0x033626D2+114] base::Thread::ThreadMain [0x032E59D6+550] base::PlatformThread::GetCurrentThreadPriority [0x032C26E5+469] BaseThreadInitThunk [0x771D336A+18] RtlInitializeExceptionChain [0x777F92B2+99] RtlInitializeExceptionChain [0x777F9285+54] Got this stack trace @ https://chromium-review.googlesource.com/c/chromium/src/+/1059459/8 when merely trying to invoke RandDouble() from a brand new thread. I suspect it's because RtlGenRandom() is marked as deprecated on MSDN and said to require manually loading Advapi32.dll before using : https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx Perhaps this happens to be okay on most threads but it isn't on a brand new threads (e.g. TaskScheduler's ServiceThread in my CL). Also, curious : this buffer should be freed by SecureZeroMemory() according to docs but it isn't in rand_util_win.cc's impl. And rand_util_win.cc's comments refer to "Community Additions" comments on MSDN which I can't find. All in all, I think this is due for a code update. @dcheng as base and security owner (in the meantime I'll just remove the random supplement added to my CL as it was just a nice-to-have)
,
May 18 2018
I concur with the rsleevi@ on all counts... but I'm replying mostly because I wanted to point out that the documentation recommends using CryptGenRandom(), which is also deprecated. Turtles... 😜 (I should also mention that loading CAPI or CNG will almost certainly break win32k lockdown, which is all manner of catastrophically bad.)
,
May 18 2018
Sounds good. gab@, it does sound like there's a real initialization issue with your patchset though, as that function should never fail (from both windbg and the FIPS security policy, it's pretty much doing unexciting things). So we should try to figure out why you're running into failures, as we want to make sure it's not sandboxing related and not related to module initialization.
,
May 18 2018
Ok thanks for your input. Maybe it's possible this thread is spun up early enough to sometimes get ahead of loading AdvApi32, but that'd be surprising to me as it's spun up during BrowserMainLoop::CreateThreads() which is early as far as initializing the browser is concerned but late as far as loading DLLs is concerned... No idea, but I also don't badly need rand there so I'll just drop it and move on..
,
May 18 2018
Yeah, I was definitely concurring with rsleevi@ on the point about it not failing. That's a critical function (the sandbox even warms it up), so something is very, very wrong if it's breaking.
,
May 18 2018
yes I agree with what's already been said here, I don't think we can change this code to call anything other than RtlGenRandom (via the SystemFunction036 trick) without risking breaking other stuff that relies on this running without massive other dependencies. I doubt this is sandbox related, but more related to just a race and advapi32.dll - perhaps it's worth writing a small test program to fire up a load of threads and call RtlGenRandom and see if you can get this to happen without sandbox.
,
May 23 2018
Here's a minimized repro : https://chromium-review.googlesource.com/c/chromium/src/+/1066458 I couldn't repro the flakes locally.
,
May 23 2018
I'm genuinely curious what happens if we were to retry RtlGenRandom on failure. 🤔
,
May 24 2018
how about trying adding an explicit load of advapi32.dll early in process startup, to check if this is a load race or not? Setting bug status so I see updates :)
,
May 24 2018
Hey Will, you're welcome to give this a shot, here's a minimized repro : https://chromium-review.googlesource.com/c/chromium/src/+/1066458. I will not be able to spend more time on this unfortunately as using rand in this code is not necessary at all and I'm already spread thin.
,
Aug 23
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by rsleevi@chromium.org
, May 18 2018