Skip to content

Commit 213aa67

Browse files
committed
parisc: Delay write-protection until mark_rodata_ro() call
Do not write-protect the kernel read-only and __ro_after_init sections earlier than before mark_rodata_ro() is called. This fixes a boot issue on parisc which is triggered by commit 91a1d97 ("jump_label,module: Don't alloc static_key_mod for __ro_after_init keys"). That commit may modify static key contents in the __ro_after_init section at bootup, so this section needs to be writable at least until mark_rodata_ro() is called. Signed-off-by: Helge Deller <[email protected]> Reported-by: matoro <[email protected]> Reported-by: Christoph Biedl <[email protected]> Tested-by: Christoph Biedl <[email protected]> Link: https://lore.kernel.org/linux-parisc/[email protected]/#r Fixes: 91a1d97 ("jump_label,module: Don't alloc static_key_mod for __ro_after_init keys") Cc: [email protected] # v6.10+
1 parent 5be63fc commit 213aa67

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

arch/parisc/mm/init.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ void free_initmem(void)
459459
unsigned long kernel_end = (unsigned long)&_end;
460460

461461
/* Remap kernel text and data, but do not touch init section yet. */
462-
kernel_set_to_readonly = true;
463462
map_pages(init_end, __pa(init_end), kernel_end - init_end,
464463
PAGE_KERNEL, 0);
465464

@@ -493,11 +492,18 @@ void free_initmem(void)
493492
#ifdef CONFIG_STRICT_KERNEL_RWX
494493
void mark_rodata_ro(void)
495494
{
496-
/* rodata memory was already mapped with KERNEL_RO access rights by
497-
pagetable_init() and map_pages(). No need to do additional stuff here */
498-
unsigned long roai_size = __end_ro_after_init - __start_ro_after_init;
495+
unsigned long start = (unsigned long) &__start_rodata;
496+
unsigned long end = (unsigned long) &__end_rodata;
497+
498+
pr_info("Write protecting the kernel read-only data: %luk\n",
499+
(end - start) >> 10);
500+
501+
kernel_set_to_readonly = true;
502+
map_pages(start, __pa(start), end - start, PAGE_KERNEL, 0);
499503

500-
pr_info("Write protected read-only-after-init data: %luk\n", roai_size >> 10);
504+
/* force the kernel to see the new page table entries */
505+
flush_cache_all();
506+
flush_tlb_all();
501507
}
502508
#endif
503509

0 commit comments

Comments
 (0)