Skip to content

Commit ad2d31c

Browse files
author
Herton R. Krzesinski
committed
Merge: x86/module: Fix the paravirt vs alternative order
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2055 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2170197 Conflicts: Minor context diffs in the first hunk due to the presence of later upstream commit ed53a0d ("x86/alternative: Use .ibt_endbr_seal to seal indirect calls") and commit 15e6722 ("x86: Undo return-thunk damage"). commit 5adf349 Author: Peter Zijlstra <peterz@infradead.org> Date: Thu, 3 Mar 2022 12:23:23 +0100 x86/module: Fix the paravirt vs alternative order 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: Waiman Long <longman@redhat.com> Approved-by: Prarit Bhargava <prarit@redhat.com> Approved-by: Dean Nelson <dnelson@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 8e6ac3f + 182546e commit ad2d31c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arch/x86/kernel/module.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ int module_finalize(const Elf_Ehdr *hdr,
277277
ibt_endbr = s;
278278
}
279279

280+
/*
281+
* See alternative_instructions() for the ordering rules between the
282+
* various patching types.
283+
*/
284+
if (para) {
285+
void *pseg = (void *)para->sh_addr;
286+
apply_paravirt(pseg, pseg + para->sh_size);
287+
}
280288
if (retpolines) {
281289
void *rseg = (void *)retpolines->sh_addr;
282290
apply_retpolines(rseg, rseg + retpolines->sh_size);
@@ -302,11 +310,6 @@ int module_finalize(const Elf_Ehdr *hdr,
302310
tseg, tseg + text->sh_size);
303311
}
304312

305-
if (para) {
306-
void *pseg = (void *)para->sh_addr;
307-
apply_paravirt(pseg, pseg + para->sh_size);
308-
}
309-
310313
/* make jump label nops */
311314
jump_label_apply_nops(me);
312315

0 commit comments

Comments
 (0)