Commit 5b384f93 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Jiri Kosina

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: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Acked-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
Acked-by: default avatarMiroslav Benes <mbenes@suse.cz>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 0d9fbf78
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/jump_label.h> #include <linux/jump_label.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/memory.h>
#include <asm/text-patching.h> #include <asm/text-patching.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -227,14 +228,18 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ...@@ -227,14 +228,18 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
bool early = me->state == MODULE_STATE_UNFORMED; bool early = me->state == MODULE_STATE_UNFORMED;
void *(*write)(void *, const void *, size_t) = memcpy; void *(*write)(void *, const void *, size_t) = memcpy;
if (!early) if (!early) {
write = text_poke; write = text_poke;
mutex_lock(&text_mutex);
}
ret = __apply_relocate_add(sechdrs, strtab, symindex, relsec, me, ret = __apply_relocate_add(sechdrs, strtab, symindex, relsec, me,
write); write);
if (!early) if (!early) {
text_poke_sync(); text_poke_sync();
mutex_unlock(&text_mutex);
}
return ret; return ret;
} }
......
...@@ -775,9 +775,6 @@ static int klp_init_object_loaded(struct klp_patch *patch, ...@@ -775,9 +775,6 @@ static int klp_init_object_loaded(struct klp_patch *patch,
int ret; int ret;
if (klp_is_module(obj)) { if (klp_is_module(obj)) {
mutex_lock(&text_mutex);
/* /*
* Only write module-specific relocations here * Only write module-specific relocations here
* (.klp.rela.{module}.*). vmlinux-specific relocations were * (.klp.rela.{module}.*). vmlinux-specific relocations were
...@@ -785,9 +782,6 @@ static int klp_init_object_loaded(struct klp_patch *patch, ...@@ -785,9 +782,6 @@ static int klp_init_object_loaded(struct klp_patch *patch,
* itself. * itself.
*/ */
ret = klp_apply_object_relocs(patch, obj); ret = klp_apply_object_relocs(patch, obj);
mutex_unlock(&text_mutex);
if (ret) if (ret)
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment