]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
arc4random: Avoid KMSAN false positives from pre-seeding results
authorMark Johnston <markj@FreeBSD.org>
Fri, 13 Aug 2021 13:52:05 +0000 (09:52 -0400)
committerMark Johnston <markj@FreeBSD.org>
Fri, 13 Aug 2021 13:58:42 +0000 (09:58 -0400)
commit3d69515cfea2781b318ebe1c6e6018d817cde358
tree5bd347c72b968fa5f924f503bc203ebdd6b61497
parente0e3ded78a5d0859f3520c541726b815897ba7b0
arc4random: Avoid KMSAN false positives from pre-seeding results

If code calls arc4random(), and our RNG is not yet seeded and
random_bypass_before_seeding is true, we'll compute a key using the
SHA256 hash of some hopefully hard-to-predict data, including the
contents of an uninitialized stack buffer (which is also the output
buffer).

When KMSAN is enabled, this use of uninitialized state propagtes through
to the arc4random() output, resulting in false positives.  To address
this, lie to KMSAN and explicitly mark the buffer as initialized.

Reviewed by: cem (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31510
sys/libkern/arc4random.c