Skip to content

Commit e7e87f0

Browse files
committed
x86/module: prepare module loading for ROX allocations of text
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. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
1 parent 18b4520 commit e7e87f0

7 files changed

Lines changed: 171 additions & 123 deletions

File tree

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)