HomeFreeBSD

arc4random: Avoid KMSAN false positives from pre-seeding results

Description

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

Details

Provenance
markjAuthored on Aug 13 2021, 1:52 PM
Reviewer
cem
Differential Revision
D31510: arc4random: Avoid KMSAN false positives from pre-seeding results
Parents
rGe0e3ded78a5d: ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine
Branches
Unknown
Tags
Unknown