x86/kaslr: Remove redundant if checks from address selection
PATCH RESEND 1/1 x86/kaslr: Remove redundant if checks from address selection
The loop in slots_fetch_random() either returns the slot address or exits with i == slot_area_index, making the if check redundant.
The if check in choose_random_location() is also unnecessary since commit 8570978ea030 ("x86/boot/compressed/64: Don't pre-map memory in KASLR code").
Remove both if checks.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/x86/boot/compressed/kaslr.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
arch/x86/boot/compressed/kaslr.c +4 -9
@@ -541,8 +541,7 @@ static u64 slots_fetch_random(void)return slot_areas[i].addr + ((u64 )slot *CONFIG_PHYSICAL_ALIGN ); } -if (i == slot_area_index) -debug_putstr ("slots_fetch_random() failed!?\n" ); +debug_putstr ("slots_fetch_random() failed!?\n" );return 0 ; }
@@ -890,14 +889,10 @@ void choose_random_location(unsigned long input,/* Walk available memory entries to find a random address. */ random_addr =find_random_phys_addr (min_addr, output_size); -if (!random_addr) { +if (!random_addr)warn ("Physical KASLR disabled: no suitable memory region!" ); - }else { -/* Update the new physical address location. */ -if (*output != random_addr) - *output = random_addr; - } - +else + *output = random_addr;/* Pick random virtual address starting from LOAD_PHYSICAL_ADDR. */ if (IS_ENABLED (CONFIG_X86_64 ))
Borislav Petkov
maintainerQuoted 6 lines · Thorsten Blum
The loop in
slots_fetch_random()either returns the slot address or exits with i ==slot_area_index, making the if check redundant.The if check in
choose_random_location()is also unnecessary since commit8570978ea030("x86/boot/compressed/64: Don't pre-map memory in KASLR code").
Sorry, you lost me here.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette