[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202007281225.C24B966D7@keescook>
Date: Tue, 28 Jul 2020 12:27:17 -0700
From: Kees Cook <keescook@...omium.org>
To: Arvind Sankar <nivedita@...m.mit.edu>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 6/8] x86/kaslr: Simplify process_gb_huge_pages
On Mon, Jul 27, 2020 at 07:07:59PM -0400, Arvind Sankar wrote:
> Short-circuit the whole function on 32-bit.
>
> Replace the loop to determine the number of 1Gb pages with arithmetic.
>
> Fix one minor bug: if the end of the region is aligned on a 1Gb
> boundary, the current code will not use the last available 1Gb page due
> to an off-by-one error.
>
> Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
Can you add some KUnit tests could be written to do validation of the
refactorings? Touching this code is so painful. :)
-Kees
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -546,49 +546,43 @@ static void store_slot_info(struct mem_vector *region, unsigned long image_size)
> static void
> process_gb_huge_pages(struct mem_vector *region, unsigned long image_size)
> {
> - unsigned long addr, size = 0;
> + unsigned long pud_start, pud_end, gb_huge_pages;
> struct mem_vector tmp;
> - int i = 0;
>
> - if (!max_gb_huge_pages) {
> + if (IS_ENABLED(CONFIG_X86_32) || !max_gb_huge_pages) {
> store_slot_info(region, image_size);
> return;
> }
Won't max_gb_huge_pages always be false for 32-bit?
--
Kees Cook
Powered by blists - more mailing lists