WILL APPLE FIX THIS?
I've posted my findings about the MacOS 11.3+ "race condition" bug, along with a patch I'm calling SurPlus,
in a github repository.
My comments after skimming through the technical details.
The race condition exists for all Macs, not just unsupported ones. It is related to the
corecrypto
module of the kernel, but does not depend on the instruction set available.
corecrypto
will use SSE3 or AES-NI, if AVX is not available.
My analysis: There was a deadlock in the kernel code as Apple first wrote it. They then implemented a workaround, but did not make sure it is always selected. SurPlus makes sure the workaround is always used by eliminating the deadlocking branch.
Technical details: The
corecrypto
and
zalloc
(memory zone allocation) threads of the kernel are in a conflict. If they call each other before both are properly initialized, the kernel will hang in a deadlock.
zalloc
needs random numbers to implement a new security feature. It gets them from
corecrypto
.
To avoid a conflict during Apple has implemented a function named
early_random()
. In a successful boot
early_random()
uses its own SHA1 random number generator. This is what it should always do during initialization.
The bug is in the
early_random()
function. Instead of generating its own random numbers, it checks to see if
corecrypto
has been initialized. If so, it calls
corecrypto
.
corecrypto
will always fail and deadlock because it needs
zalloc
.
SurPlus fixes the bug by simply removing the conditional branch to
corecrypto
in the
zalloc
initialization code. I believe Apple should do the same.
A patch to mitigate the Big Sur/Monterey race condition - reenigneorcim/SurPlus
github.com
P.S.
I assume
early_random()
is only called by the initialization code for
zalloc
. If not, then another way for Apple to fix
early_random()
would be for it to check that both
corecrypto
and
zalloc
are initialized. But this would provide little benefit from an ugly clutch.
Randomizing memory addresses are generally used to mitigate
side-channel attacks.