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
F165167531: D44029.diff
Thu, Aug 6, 12:54 PM
Unknown Object (File)
Mon, Jul 27, 2:38 PM
Unknown Object (File)
Sun, Jul 26, 3:43 PM
Unknown Object (File)
Sun, Jul 26, 2:59 PM
Unknown Object (File)
Fri, Jul 24, 6:09 PM
Unknown Object (File)
Wed, Jul 22, 4:56 PM
Unknown Object (File)
Wed, Jul 22, 11:26 AM
Unknown Object (File)
Jul 3 2026, 6:33 AM
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