summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/module.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2020-04-29 18:24:52 +0300
committerJiri Kosina <jkosina@suse.cz>2020-05-08 01:12:43 +0300
commit5b384f933590a086ca9a0abdc2e55e41107ac440 (patch)
treec0e8eff59863dce168272dacd518d6ce26d93314 /arch/x86/kernel/module.c
parent0d9fbf78fefb421a3af97394ce80bba0db4f046a (diff)
downloadlinux-5b384f933590a086ca9a0abdc2e55e41107ac440.tar.xz
x86/module: Use text_mutex in apply_relocate_add()
Now that the livepatch code no longer needs the text_mutex for changing module permissions, move its usage down to apply_relocate_add(). Note the s390 version of apply_relocate_add() doesn't need to use the text_mutex because it already uses s390_kernel_write_lock, which accomplishes the same task. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Joe Lawrence <joe.lawrence@redhat.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'arch/x86/kernel/module.c')
-rw-r--r--arch/x86/kernel/module.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 7614f478fd7a..23c95a53d20e 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -18,6 +18,7 @@
#include <linux/gfp.h>
#include <linux/jump_label.h>
#include <linux/random.h>
+#include <linux/memory.h>
#include <asm/text-patching.h>
#include <asm/page.h>
@@ -227,14 +228,18 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
bool early = me->state == MODULE_STATE_UNFORMED;
void *(*write)(void *, const void *, size_t) = memcpy;
- if (!early)
+ if (!early) {
write = text_poke;
+ mutex_lock(&text_mutex);
+ }
ret = __apply_relocate_add(sechdrs, strtab, symindex, relsec, me,
write);
- if (!early)
+ if (!early) {
text_poke_sync();
+ mutex_unlock(&text_mutex);
+ }
return ret;
}