-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Feature Request
Currently, the x86 kernel is loaded into a fixed physical address and runs at a fixed virtual address. Physical/Virtual KASLR is not available, as it is only handled for bzImage during decompression, missing out on an additional layer of defense against code reuse attacks. KASLR is easily broken by information leaks, but since Firecracker uses short-lived VMs, KASLR might be a desirable feature because the VMs will be frequently re-randomized.
Describe the desired solution
-
Physical KASLR
kernel_offsetargument toloader::elf::Elf::load()effectively does physical KASLR by allowing the kernel to be loaded at an offset from the default atCONFIG_PHYSICAL_START. So we only need to provide akernel_offsetthat is aligned toCONFIG_PHYSICAL_ALIGNED.
For PVH entry, the current code in linux_loader doesn't support physical KASLR. If we provide a kernel_offset, it will choose to use the Linux 64-bit boot protocol. However, in the Linux kernel, physical KASLR for PVH entry has been allowed since commit 47ffe0578aee45fed3a06d5dcff76cdebb303163 which introduced a new PVH ELF note that imposes the relocation range. I can change the handling inlinux_loaderto adapt to this. -
Virtual KASLR
There is no available function inlinux_loaderfor now. However, it is easily to implemented, all we need is the relocation information for kernel. In x86 kernel, there is avmlinux.relocsfile which contains all relocation information needed, so what we need is to read it and perform relocation likehandle_relocations()inarch/x86/boot/compressed/misc.c. The only discussion is where to implement it: inFirecrackerorlinux_loader.
Describe possible alternatives
As for virtual KASLR, I have another possible implementation approach: to do it directly in the kernel when booting from vmlinux, see this patchset, then it doesn't need any changes in VMM, however, I'm not sure if it would be acceptable by the x86 folks.
Additional context
Checks
- [*] Have you searched the Firecracker Issues database for similar requests?
- [*] Have you read all the existing relevant Firecracker documentation?
- [*] Have you read and understood Firecracker's core tenets?