Page MenuHomeFreeBSD

lib/libcrypt: use explicit_bzero() to clear sensitive buffers
ClosedPublic

Authored by fuz on Oct 10 2024, 9:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 14, 9:58 PM
Unknown Object (File)
Mon, Dec 9, 5:53 AM
Unknown Object (File)
Nov 23 2024, 11:14 PM
Unknown Object (File)
Nov 21 2024, 7:16 AM
Unknown Object (File)
Nov 20 2024, 7:01 PM
Unknown Object (File)
Nov 18 2024, 2:01 PM
Unknown Object (File)
Nov 6 2024, 5:08 PM
Unknown Object (File)
Nov 6 2024, 11:28 AM
Subscribers

Details

Summary

Prevent a potentially sufficiently smart compiler from optimising
away our attempts to clear sensitive buffers.

A related change was discussed and rejected in D16059, but I don't
believe the reasoning there applies: the code clearly documents its
intent that the memset calls clear sensitive buffers so they don't
hang around. explicit_bzero is the appropriate function for this
purpose. A potential performance disadvantage seems less important:
the functions in crypt are specifically designed to be slow, so a
few extra calls to guarantee that sensitive buffers are cleared does
not significantly affect runtime.

Test Plan

Passes test suite, no functional changes.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable