Re: [PATCH 3/3] MIPS: KASLR: Make relocation_address can be configured

From: Jinyang He
Date: Thu Nov 19 2020 - 21:43:30 EST


Hi,

On 11/19/2020 08:45 PM, Thomas Bogendoerfer wrote:
On Thu, Nov 19, 2020 at 10:29:14AM +0800, Jinyang He wrote:
When CONFIG_RANDOMIZE_BASE is not set, determine_relocation_address()
always returns a constant. It is not friendly to users if the address
cannot be used. Make it can be configured at Kconfig.
and how do I get the information which address I need to enter ?
This looks more like platforms need to supply a working address and
not the user configuring the kernel...
You are right.

We only have two address to enter if CONFIG_RANDOMIZE_BASE disabled. One
is 0xffffffff81000000 in the current if succeed, the other is the orignal
address if failed. From relocation_addr_valid() we see that the avaliable
address need to higher than &_end to avoid overlaps original kernel.
E.g. 0xffffffff83000000 and 0xffffffff84000000 both is avaliable on
Loongson64 platform when &_end == 0xffffffff82213f80. But
0xffffffff82000000 is not available in that case.

In reality test, I compiled kernel first and got &_end. And then modified
the relocate_address to avaliable and compiled kernel once more. It is
a bad idea.

Is it different from modifying CONFIG_PHYSICAL_START when just relocate
one address? Does it make sense if only one address to relocate?

Morever, RANDOMIZE_BASE is normally avaliable. Can we add a kernel
parameter like "relocation=0xffffffff81000000" to direct address?
At least, other architecture disabling RANDOMIZE_BASE looks like "nokaslr".
Thus, can we delete these code which RANDOMIZE_BASE disabled?

Thanks! :-)
Jinyang

Thomas.