lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200728194511.GB4150860@rani.riverdale.lan>
Date:   Tue, 28 Jul 2020 15:45:11 -0400
From:   Arvind Sankar <nivedita@...m.mit.edu>
To:     Kees Cook <keescook@...omium.org>
Cc:     Arvind Sankar <nivedita@...m.mit.edu>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 6/8] x86/kaslr: Simplify process_gb_huge_pages

On Tue, Jul 28, 2020 at 12:27:17PM -0700, Kees Cook wrote:
> 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

Can I try to do that later -- I've never written a KUnit test, though
it's probably a good opportunity to learn how to do one.

> 
> > +++ 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

It will, assuming someone doesn't pass bogus command-line arguments to
reserve Gb pages on 32-bit.

But the IS_ENABLED check allows the compiler to eliminate the entire
function at compile time.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ