lkml.org 
[lkml]   [2020]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 8/8] x86/kaslr: Don't use 64-bit mem_vector for 32-bit kernel

* Arvind Sankar <nivedita@alum.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

\
 
 \ /
  Last update: 2020-07-28 13:05    [W:0.302 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site