Skip to content
Commit d7fe913f authored by Alper Nebi Yasak's avatar Alper Nebi Yasak Committed by Heinrich Schuchardt
Browse files

efi_loader: Avoid underflow when calculating remaining var store size



The efi_var_mem_free() function calculates the available size for a new
EFI variable by subtracting the occupied buffer size and the overhead
for a new variable from the maximum buffer size set in Kconfig. This
is then returned as QueryVariableInfo()'s RemainingVariableStorageSize
output.

This can underflow as the calculation is done in and processed as
unsigned integer types. Check for underflow before doing the subtraction
and return zero if there's no space.

Fixes: f1f990a8 ("efi_loader: memory buffer for variables")
Signed-off-by: default avatarAlper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: default avatarHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
parent 0ef63434
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment