• Ard Biesheuvel's avatar
    efi/libstub/random: Align allocate size to EFI_ALLOC_ALIGN · e1df73e2
    Ard Biesheuvel authored
    The EFI stub uses a per-architecture #define for the minimum base
    and size alignment of page allocations, which is set to 4 KB for
    all architecures except arm64, which uses 64 KB, to ensure that
    allocations can always be (un)mapped efficiently, regardless of
    the page size used by the kernel proper, which could be a kexec'ee
    
    The API wrappers around page based allocations assume that this
    alignment is always taken into account, and so efi_free() will
    also round up its size argument to EFI_ALLOC_ALIGN.
    
    Currently, efi_random_alloc() does not honour this alignment for
    the allocated size, and so freeing such an allocation may result
    in unrelated memory to be freed, potentially leading to issues
    after boot. So let's round up size in efi_random_alloc() as well.
    
    Fixes: 2ddbfc81 ("efi: stub: add implementation of efi_random_alloc()")
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    e1df73e2
randomalloc.c 3.48 KB