Skip to content

Commit 2f60f83

Browse files
committed
Merge tag 'x86_alternatives_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 alternative update from Borislav Petkov: "A single alternatives patching fix for modules: - Have alternatives patch the same sections in modules as in vmlinux" * tag 'x86_alternatives_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/alternative: Consistently patch SMP locks in vmlinux and modules
2 parents 9196a0b + be84d8e commit 2f60f83

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/x86/kernel/module.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,12 @@ int module_finalize(const Elf_Ehdr *hdr,
251251
const Elf_Shdr *sechdrs,
252252
struct module *me)
253253
{
254-
const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
254+
const Elf_Shdr *s, *alt = NULL, *locks = NULL,
255255
*para = NULL, *orc = NULL, *orc_ip = NULL,
256256
*retpolines = NULL, *returns = NULL, *ibt_endbr = NULL;
257257
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
258258

259259
for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
260-
if (!strcmp(".text", secstrings + s->sh_name))
261-
text = s;
262260
if (!strcmp(".altinstructions", secstrings + s->sh_name))
263261
alt = s;
264262
if (!strcmp(".smp_locks", secstrings + s->sh_name))
@@ -302,12 +300,13 @@ int module_finalize(const Elf_Ehdr *hdr,
302300
void *iseg = (void *)ibt_endbr->sh_addr;
303301
apply_ibt_endbr(iseg, iseg + ibt_endbr->sh_size);
304302
}
305-
if (locks && text) {
303+
if (locks) {
306304
void *lseg = (void *)locks->sh_addr;
307-
void *tseg = (void *)text->sh_addr;
305+
void *text = me->core_layout.base;
306+
void *text_end = text + me->core_layout.text_size;
308307
alternatives_smp_module_add(me, me->name,
309308
lseg, lseg + locks->sh_size,
310-
tseg, tseg + text->sh_size);
309+
text, text_end);
311310
}
312311

313312
if (orc && orc_ip)

0 commit comments

Comments
 (0)