Skip to content

Commit 74226bd

Browse files
committed
x86/module: prepare module loading for ROX allocations of text
jira LE-4694 Rebuild_History Non-Buildable kernel-6.12.0-55.43.1.el10_0 commit-author Mike Rapoport (Microsoft) <[email protected]> commit 9bfc482 When module text memory will be allocated with ROX permissions, the memory at the actual address where the module will live will contain invalid instructions and there will be a writable copy that contains the actual module code. Update relocations and alternatives patching to deal with it. [[email protected]: fix writable address in cfi_rewrite_endbr()] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> Tested-by: kdevops <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Cc: Andreas Larsson <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dinh Nguyen <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Guo Ren <[email protected]> Cc: Helge Deller <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Johannes Berg <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Luis Chamberlain <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu (Google) <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Russell King <[email protected]> Cc: Song Liu <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Steven Rostedt (Google) <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Uladzislau Rezki (Sony) <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 9bfc482) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 5a9e6da commit 74226bd

File tree

6 files changed

+167
-117
lines changed

6 files changed

+167
-117
lines changed

arch/um/kernel/um_arch.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,24 +435,25 @@ void __init arch_cpu_finalize_init(void)
435435
os_check_bugs();
436436
}
437437

438-
void apply_seal_endbr(s32 *start, s32 *end)
438+
void apply_seal_endbr(s32 *start, s32 *end, struct module *mod)
439439
{
440440
}
441441

442-
void apply_retpolines(s32 *start, s32 *end)
442+
void apply_retpolines(s32 *start, s32 *end, struct module *mod)
443443
{
444444
}
445445

446-
void apply_returns(s32 *start, s32 *end)
446+
void apply_returns(s32 *start, s32 *end, struct module *mod)
447447
{
448448
}
449449

450450
void apply_fineibt(s32 *start_retpoline, s32 *end_retpoline,
451-
s32 *start_cfi, s32 *end_cfi)
451+
s32 *start_cfi, s32 *end_cfi, struct module *mod)
452452
{
453453
}
454454

455-
void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
455+
void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
456+
struct module *mod)
456457
{
457458
}
458459

arch/x86/entry/vdso/vma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ int __init init_vdso_image(const struct vdso_image *image)
5454

5555
apply_alternatives((struct alt_instr *)(image->data + image->alt),
5656
(struct alt_instr *)(image->data + image->alt +
57-
image->alt_len));
57+
image->alt_len),
58+
NULL);
5859

5960
return 0;
6061
}

arch/x86/include/asm/alternative.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
9696
* instructions were patched in already:
9797
*/
9898
extern int alternatives_patched;
99+
struct module;
99100

100101
extern void alternative_instructions(void);
101-
extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
102-
extern void apply_retpolines(s32 *start, s32 *end);
103-
extern void apply_returns(s32 *start, s32 *end);
104-
extern void apply_seal_endbr(s32 *start, s32 *end);
102+
extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
103+
struct module *mod);
104+
extern void apply_retpolines(s32 *start, s32 *end, struct module *mod);
105+
extern void apply_returns(s32 *start, s32 *end, struct module *mod);
106+
extern void apply_seal_endbr(s32 *start, s32 *end, struct module *mod);
105107
extern void apply_fineibt(s32 *start_retpoline, s32 *end_retpoine,
106-
s32 *start_cfi, s32 *end_cfi);
107-
108-
struct module;
108+
s32 *start_cfi, s32 *end_cfi, struct module *mod);
109109

110110
struct callthunk_sites {
111111
s32 *call_start, *call_end;

0 commit comments

Comments
 (0)