Page MenuHomeFreeBSD

efibootmgr: Simplify make_next_boot_var_name and fix cnt == 0 case
ClosedPublic

Authored by jrtc27 on Feb 22 2024, 11:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 5:45 AM
Unknown Object (File)
Sat, Apr 27, 12:16 PM
Unknown Object (File)
Fri, Apr 26, 12:51 PM
Unknown Object (File)
Fri, Apr 26, 3:37 AM
Unknown Object (File)
Tue, Apr 23, 10:13 AM
Unknown Object (File)
Feb 24 2024, 8:09 PM
Subscribers
None

Details

Summary

If cnt == 0 we access element 0 unconditionally, which is out of bounds,
and then if that doesn't crash and happens to be 0 we will access
element - 1, also out of bounds, and then if that doesn't crash will add
1 to whatever junk is there and use that for the variable. On CHERI,
though, this does crash. This code is also overly complicated, with
unnecessary special cases and tracking more state than needed.

Rewrite it in a more general manner that doesn't need those special
cases and naturally works for cnt == 0.

Found by: CHERI
Fixes: 1285bcc833a3 ("Import Netflix's efibootmgr to help manage UEFI boot variables")
MFC after: 1 week

Diff Detail

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