Skip to content

Commit

Permalink
x86/module: Fix the paravirt vs alternative order
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Greg Kroah-Hartman committed Mar 19, 2022
1 parent ff2e93a commit df3817a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions arch/x86/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ int module_finalize(const Elf_Ehdr *hdr,
orc_ip = s;
}

/*
* See alternative_instructions() for the ordering rules between the
* various patching types.
*/
if (para) {
void *pseg = (void *)para->sh_addr;
apply_paravirt(pseg, pseg + para->sh_size);
}
if (alt) {
/* patch .altinstructions */
void *aseg = (void *)alt->sh_addr;
Expand All @@ -283,11 +291,6 @@ int module_finalize(const Elf_Ehdr *hdr,
tseg, tseg + text->sh_size);
}

if (para) {
void *pseg = (void *)para->sh_addr;
apply_paravirt(pseg, pseg + para->sh_size);
}

/* make jump label nops */
jump_label_apply_nops(me);

Expand Down

0 comments on commit df3817a

Please sign in to comment.