[PATCH 0/2] arm64: permit KASLR in linear region even VArange == PArange
Kefeng Wang
wangkefeng.wang at huawei.com
Thu Dec 16 03:32:29 PST 2021
On 2021/12/16 16:56, Ard Biesheuvel wrote:
> (+ Marc)
>
> On Thu, 16 Dec 2021 at 08:37, Kefeng Wang <wangkefeng.wang at huawei.com> wrote:
>>
>> On 2021/12/15 22:52, Ard Biesheuvel wrote:
>>> Kefeng reports in [0] that using PArange to size the randomized linear
>>> region offset leads to cases where randomization is no longer possible
>>> even if the actual placement of DRAM in memory would otherwise have
>>> permitted it.
>>>
>>> Instead of using CONFIG_MEMORY_HOTPLUG to choose at build time between
>>> to different behaviors in this regard, let's try addressing this by
>>> reducing the minimum relative aligment between VA and PA in the linear
>>> region, and taking advantage of the space at the base of physical memory
>>> below the first memblock to permit some randomization of the placement
>>> of physical DRAM in the virtual address map.
>> VArange == PArange is ok, but our case is Va=39/Pa=48, this is still not
>> works :(
>>
>> Could we add a way(maybe cmdline) to set max parange, then we could make
>>
>> randomization works, or some other way?
>>
> We could, but it is not a very elegant way to recover this
> randomization range. You would need to reduce the PArange to 36 bits
> (which is the next valid option below 40) in order to ensure that a
> 39-bit VA kernel has some room for randomization, but this would not
> work on many systems because they require 40-bit physical addressing,
> due to the placement of DRAM in the PA space, not the DRAM size.
Yes, cmdline is not elegant, we can't find a better way to fix this.
> Android 5.10 is in the same boat (and needs CONFIG_MEMORY_HOTPLUG=y)
> so I agree we need something better here.
It's not only Android, some embedded system with not too much memory, they
need KASLR/MEMORY_HOTPLUG.
>
>
>
>>> Cc: Kefeng Wang <wangkefeng.wang at huawei.com>
>>>
>>> [0] https://lore.kernel.org/linux-arm-kernel/20211104062747.55206-1-wangkefeng.wang@huawei.com/
>>>
>>> Ard Biesheuvel (2):
>>> arm64: simplify rules for defining ARM64_MEMSTART_ALIGN
>>> arm64: kaslr: take free space at start of DRAM into account
>>>
>>> arch/arm64/include/asm/kernel-pgtable.h | 27 +++-----------------
>>> arch/arm64/mm/init.c | 3 ++-
>>> 2 files changed, 6 insertions(+), 24 deletions(-)
>>>
> .
More information about the linux-arm-kernel
mailing list