mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
um: mprotect() __init memory
Unlike what the comment says, we could munmap() this (but not reuse it for guest allocations), but then stray libc allocations could technically conflict, so mprotect() it to catch access bugs. Align it in the linker scripts too so that all of it can be covered, not just some. Link: https://patch.msgid.link/20260924084946.d118ec78e604.I993b671566a4e842dcc290b78f1c0004050362ba@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
8966ed0b2d
commit
a418ab8fdd
|
|
@ -24,9 +24,8 @@ SECTIONS
|
|||
INIT_TEXT_SECTION(PAGE_SIZE)
|
||||
|
||||
init.data : { INIT_DATA }
|
||||
__init_end = .;
|
||||
|
||||
. = ALIGN(PAGE_SIZE);
|
||||
__init_end = .;
|
||||
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
|
|
|
|||
|
|
@ -83,12 +83,17 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
|
|||
}
|
||||
|
||||
/*
|
||||
* This can't do anything because nothing in the kernel image can be freed
|
||||
* since it's not in kernel physical memory.
|
||||
* We could munmap() this instead, but then libc allocations could
|
||||
* land in this area and stray initdata access could erroneously
|
||||
* succeed - just mprotect() it to reliably catch bad accesses.
|
||||
*/
|
||||
|
||||
void free_initmem(void)
|
||||
{
|
||||
unsigned long start = PAGE_ALIGN((unsigned long)__init_begin);
|
||||
unsigned long end = round_down((unsigned long)__init_end, PAGE_SIZE);
|
||||
|
||||
if (end > start)
|
||||
os_protect_memory((void *)start, end - start, 0, 0, 0);
|
||||
}
|
||||
|
||||
void *uml_kmalloc(int size, int flags)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ SECTIONS
|
|||
INIT_TEXT_SECTION(0)
|
||||
|
||||
init.data : { INIT_DATA }
|
||||
. = ALIGN(PAGE_SIZE);
|
||||
__init_end = .;
|
||||
|
||||
.text :
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user