APPLIED [R/unstable] Re: [SRU][J/N/Q/R:Unstable][PATCH 0/1] efi: Fix swapped bsearch arguments in SAUCE patch
Timo Aaltonen
timo.aaltonen at canonical.com
Wed Mar 4 13:11:52 UTC 2026
Dongdong Tao kirjoitti 10.2.2026 klo 7.14:
> BugLink: https://bugs.launchpad.net/bugs/2141276
>
> == SRU Justification ==
>
> [Impact]
> The SAUCE patch "UBUNTU: SAUCE: (lockdown) Add efi_status_to_str() and
> rework efi_status_to_err()" contains a bug where the 3rd and 4th arguments
> to bsearch() are swapped.
>
> The bsearch() signature is:
> void *bsearch(key, base, nmemb, size, compar)
>
> Current code passes: (sizeof(struct efi_error_code), num) -- WRONG
> Should be: (num, sizeof(struct efi_error_code)) -- CORRECT
>
> This causes bsearch to calculate incorrect element offsets:
> - Buggy: thinks 24 elements of 12 bytes each
> - Correct: should be 12 elements of 24 bytes each
>
> This may cause efi_status_to_err() and efi_status_to_str() to return
> incorrect error codes or fail to find valid status codes.
>
> [Test Plan]
> 1. Boot system with EFI firmware
> 2. Trigger EFI error conditions (e.g., secure boot violations)
> 3. Verify correct error messages are displayed
> 4. Check dmesg for proper EFI status code translations
>
> [Where problems could occur]
> The fix is a straightforward argument swap with no functional changes.
> Risk is minimal as this corrects the code to match the documented
> bsearch() API.
>
> [Other]
> This fix has been merged upstream in kernel-ark:
> https://gitlab.com/cki-project/kernel-ark/-/commit/49bcc48074ba
>
> Dongdong Tao (1):
> UBUNTU: SAUCE: efi: Fix swapped arguments to bsearch() in
> efi_status_to_*()
>
> drivers/firmware/efi/efi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --
> 2.39.5
>
applied to resolute and unstable with the amendments
--
Timo Aaltonen
Kernel Team
Canonical Ltd.
More information about the kernel-team
mailing list