mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
![Andreas Kling](/assets/img/avatar_default.png)
You can now declare functions with UNMAP_AFTER_INIT and they'll get segregated into a separate kernel section that gets completely unmapped at the end of initialization. This can be used for anything we don't need to call once we've booted into userspace. There are two nice things about this mechanism: - It allows us to free up entire pages of memory for other use. (Note that this patch does not actually make use of the freed pages yet, but in the future we totally could!) - It allows us to get rid of obviously dangerous gadgets like write-to-CR0 and write-to-CR4 which are very useful for an attacker trying to disable SMAP/SMEP/etc. I've also made sure to include a helpful panic message in case you hit a kernel crash because of this protection. :^)
77 lines
1.6 KiB
Plaintext
77 lines
1.6 KiB
Plaintext
ENTRY(start)
|
|
|
|
SECTIONS
|
|
{
|
|
. = 0xc0100000;
|
|
|
|
start_of_kernel_image = .;
|
|
|
|
.text ALIGN(4K) : AT (ADDR(.text) - 0xc0000000)
|
|
{
|
|
$<TARGET_OBJECTS:boot>
|
|
*(.multiboot)
|
|
start_of_kernel_text = .;
|
|
|
|
start_of_safemem_text = .;
|
|
KEEP(*(.text.safemem))
|
|
end_of_safemem_text = .;
|
|
start_of_safemem_atomic_text = .;
|
|
KEEP(*(.text.safemem.atomic))
|
|
end_of_safemem_atomic_text = .;
|
|
|
|
*(.text*)
|
|
}
|
|
|
|
.unmap_after_init ALIGN(4K) : AT (ADDR(.unmap_after_init) - 0xc0000000)
|
|
{
|
|
start_of_unmap_after_init = .;
|
|
*(.unmap_after_init*);
|
|
end_of_unmap_after_init = .;
|
|
|
|
end_of_kernel_text = .;
|
|
}
|
|
|
|
.rodata ALIGN(4K) : AT (ADDR(.rodata) - 0xc0000000)
|
|
{
|
|
start_heap_ctors = .;
|
|
*libkernel_heap.a:*(.ctors)
|
|
end_heap_ctors = .;
|
|
|
|
start_ctors = .;
|
|
*(.ctors)
|
|
end_ctors = .;
|
|
|
|
*(.rodata*)
|
|
}
|
|
|
|
.data ALIGN(4K) : AT (ADDR(.data) - 0xc0000000)
|
|
{
|
|
start_of_kernel_data = .;
|
|
*(.data*)
|
|
end_of_kernel_data = .;
|
|
}
|
|
|
|
.ro_after_init ALIGN(4K) (NOLOAD) : AT(ADDR(.ro_after_init) - 0xc0000000)
|
|
{
|
|
start_of_ro_after_init = .;
|
|
*(.ro_after_init);
|
|
end_of_ro_after_init = .;
|
|
}
|
|
|
|
.bss ALIGN(4K) (NOLOAD) : AT (ADDR(.bss) - 0xc0000000)
|
|
{
|
|
start_of_kernel_bss = .;
|
|
*(page_tables)
|
|
*(COMMON)
|
|
*(.bss)
|
|
end_of_kernel_bss = .;
|
|
|
|
. = ALIGN(4K);
|
|
*(.heap)
|
|
. = ALIGN(4K);
|
|
*(.super_pages)
|
|
}
|
|
|
|
end_of_kernel_image = .;
|
|
}
|