Skip to content

Commit df3817a

Browse files
Peter Zijlstragregkh
authored andcommitted
x86/module: Fix the paravirt vs alternative order
commit 5adf349 upstream. Ever since commit 4e62921 ("x86/paravirt: Add new features for paravirt patching") there is an ordering dependency between patching paravirt ops and patching alternatives, the module loader still violates this. Fixes: 4e62921 ("x86/paravirt: Add new features for paravirt patching") Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20220303112825.068773913@infradead.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff2e93a commit df3817a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

arch/x86/kernel/module.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ int module_finalize(const Elf_Ehdr *hdr,
270270
orc_ip = s;
271271
}
272272

273+
/*
274+
* See alternative_instructions() for the ordering rules between the
275+
* various patching types.
276+
*/
277+
if (para) {
278+
void *pseg = (void *)para->sh_addr;
279+
apply_paravirt(pseg, pseg + para->sh_size);
280+
}
273281
if (alt) {
274282
/* patch .altinstructions */
275283
void *aseg = (void *)alt->sh_addr;
@@ -283,11 +291,6 @@ int module_finalize(const Elf_Ehdr *hdr,
283291
tseg, tseg + text->sh_size);
284292
}
285293

286-
if (para) {
287-
void *pseg = (void *)para->sh_addr;
288-
apply_paravirt(pseg, pseg + para->sh_size);
289-
}
290-
291294
/* make jump label nops */
292295
jump_label_apply_nops(me);
293296

0 commit comments

Comments
 (0)