]> git.baikalelectronics.ru Git - kernel.git/commit
efi: stub: add implementation of efi_random_alloc()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 11 Jan 2016 09:43:16 +0000 (10:43 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 24 Feb 2016 14:57:28 +0000 (14:57 +0000)
commit0eb2ede1315240a86861eba735a16ff106a6bca7
tree958da4ff15f5fc23a4d65a427a41537a6a747cfb
parenta62cf2d9c797ed125a4d343d331b28ff90288929
efi: stub: add implementation of efi_random_alloc()

This implements efi_random_alloc(), which allocates a chunk of memory of
a certain size at a certain alignment, and uses the random_seed argument
it receives to randomize the address of the allocation.

This is implemented by iterating over the UEFI memory map, counting the
number of suitable slots (aligned offsets) within each region, and picking
a random number between 0 and 'number of slots - 1' to select the slot,
This should guarantee that each possible offset is chosen equally likely.

Suggested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
drivers/firmware/efi/libstub/efistub.h
drivers/firmware/efi/libstub/random.c