littlekernel / lk

LK embedded kernel
MIT License
3.11k stars 613 forks source link

ASLR support? #339

Open xx24678 opened 1 year ago

xx24678 commented 1 year ago

Sorry I don't see any document mentioning this: Is there a guide on how to enable ASLR for little kernel?

travisg commented 1 year ago

There is no such support at the moment, though I think in general it wouldn't be too hard to add, depending on which architecture the intended use case is.

A) It probably only makes sense on architectures with an MMU, which reduces the use case to x86-32/64, riscv32 and 64, and arm32 and arm64. B) The system would need to be compiled position independent but some self-relocation would probably need to be done at boot, though that may be handled by whatever bootloader is in use. C) getting access to early entropy enough to randomly decide would be a fairly problematic thing to do generically, so it'd have to be solved on a per device basis.

However if the bootloader and device has the required support it wouldn't e a tremendously difficult thing to add at the kernel level.