[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200728110512.GE222284@gmail.com>
Date: Tue, 28 Jul 2020 13:05:12 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Arvind Sankar <nivedita@...m.mit.edu>
Cc: Kees Cook <keescook@...omium.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 8/8] x86/kaslr: Don't use 64-bit mem_vector for 32-bit
kernel
* Arvind Sankar <nivedita@...m.mit.edu> wrote:
> Commit
> f28442497b5c ("x86/boot: Fix KASLR and memmap= collision")
> converted mem_vector type to use 64-bit on the 32-bit kernel as well,
> based on Thomas's review [0]. However:
> - the code still doesn't consistently use 64-bit types. For instance,
> mem_avoid_overlap uses 32-bit types when checking for overlaps. This
> is actually okay, as the passed in memory range will have been clipped
> to below 4G, but it is difficult to reason about the safety of the
> code.
> - KASLR on 32-bit can't use memory above 4G anyway, so it's pointless
> to keep track of ranges above 4G.
>
> Switch the type back to unsigned long, and use a helper function to clip
> regions to 4G on 32-bit, when storing mem_avoid, immovable_mem, EFI,
> E820 and command-line memory regions.
>
> [0] https://lore.kernel.org/linux-nvdimm/alpine.DEB.2.20.1701111246400.3579@nanos/
So why not just standardize all the calculations around u64, and for
32-bit kernels add in a debug check that double checks that it all
remained within the first 32 bits?
It's much easier to argue about this if we don't have to worry about
32-bit overflows and if the types are simple and bitness invariant.
Yes, technically it's slightly bloated on 32-bit kernels, but
maintainability of 32-bit kernels is the primary concern now ...
Thanks,
Ingo
Powered by blists - more mailing lists