From: Peter Zijlstra <peterz@infradead.org>
To: tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: hch@infradead.org, sean.j.christopherson@intel.com,
mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org,
kenny@panix.com, peterz@infradead.org, jeyu@kernel.org,
rasmus.villemoes@prevas.dk, pbonzini@redhat.com,
fenghua.yu@intel.com, xiaoyao.li@intel.com, nadav.amit@gmail.com,
thellstrom@vmware.com, tony.luck@intel.com, rostedt@goodmis.org,
gregkh@linuxfoundation.org, jannh@google.com,
keescook@chromium.org, David.Laight@aculab.com,
dcovelli@vmware.com, mhiramat@kernel.org
Subject: [PATCH 2/4] module: Convert module_finalize() to load_info
Date: Tue, 07 Apr 2020 13:02:38 +0200 [thread overview]
Message-ID: <20200407111007.276421550@infradead.org> (raw)
In-Reply-To: 20200407110236.930134290@infradead.org
Provide load_info to module_finalize(), such that architectures might,
for example, use get_modinfo() in their implementation.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/arc/kernel/module.c | 4 ++--
arch/arm/kernel/module.c | 5 +++--
arch/arm64/kernel/module.c | 6 +++---
arch/ia64/kernel/module.c | 3 +--
arch/m68k/kernel/module.c | 4 +---
arch/microblaze/kernel/module.c | 3 +--
arch/mips/kernel/module.c | 6 +++---
arch/nds32/kernel/module.c | 4 +---
arch/nios2/kernel/module.c | 3 +--
arch/parisc/kernel/module.c | 6 +++---
arch/powerpc/kernel/module.c | 5 +++--
arch/s390/kernel/module.c | 6 +++---
arch/sh/kernel/module.c | 6 +++---
arch/sparc/kernel/module.c | 7 ++++---
arch/x86/kernel/module.c | 6 +++---
include/linux/moduleloader.h | 4 +---
kernel/module.c | 6 ++----
17 files changed, 38 insertions(+), 46 deletions(-)
--- a/arch/arc/kernel/module.c
+++ b/arch/arc/kernel/module.c
@@ -129,10 +129,10 @@ int apply_relocate_add(Elf32_Shdr *sechd
* This couldn't be done in module_frob_arch_sections() because
* relocations had not been applied by then
*/
-int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
- struct module *mod)
+int module_finalize(const struct load_info *info, struct module *mod)
{
#ifdef CONFIG_ARC_DW2_UNWIND
+ const Elf_Shdr *sechdrs = info->sechdrs;
void *unw;
int unwsec = mod->arch.unw_sec_idx;
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -340,9 +340,10 @@ static const Elf_Shdr *find_mod_section(
extern void fixup_pv_table(const void *, unsigned long);
extern void fixup_smp(const void *, unsigned long);
-int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
- struct module *mod)
+int module_finalize(const struct load_info *info, struct module *mod)
{
+ const Elf32_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *s = NULL;
#ifdef CONFIG_ARM_UNWIND
const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -515,10 +515,10 @@ static int module_init_ftrace_plt(const
return 0;
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *s;
s = find_section(hdr, sechdrs, ".altinstructions");
if (s)
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -902,8 +902,7 @@ register_unwind_table (struct module *mo
}
}
-int
-module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mod)
+int module_finalize(const struct load_info *info, struct module *mod)
{
DEBUGP("%s: init: entry=%p\n", __func__, mod->init);
if (mod->arch.unwind)
--- a/arch/m68k/kernel/module.c
+++ b/arch/m68k/kernel/module.c
@@ -99,9 +99,7 @@ int apply_relocate_add(Elf32_Shdr *sechd
return 0;
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *mod)
+int module_finalize(const struct load_info *info, struct module *mod)
{
module_fixup(mod, mod->arch.fixup_start, mod->arch.fixup_end);
return 0;
--- a/arch/microblaze/kernel/module.c
+++ b/arch/microblaze/kernel/module.c
@@ -114,8 +114,7 @@ int apply_relocate_add(Elf32_Shdr *sechd
return 0;
}
-int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
- struct module *module)
+int module_finalize(const struct load_info *info, struct module *module)
{
flush_dcache();
return 0;
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -427,10 +427,10 @@ const struct exception_table_entry *sear
}
/* Put in dbe list if necessary. */
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *s;
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
--- a/arch/nds32/kernel/module.c
+++ b/arch/nds32/kernel/module.c
@@ -266,9 +266,7 @@ apply_relocate_add(Elf32_Shdr * sechdrs,
return 0;
}
-int
-module_finalize(const Elf32_Ehdr * hdr, const Elf_Shdr * sechdrs,
- struct module *module)
+int module_finalize(const struct load_info *info, struct module *module)
{
return 0;
}
--- a/arch/nios2/kernel/module.c
+++ b/arch/nios2/kernel/module.c
@@ -130,8 +130,7 @@ int apply_relocate_add(Elf32_Shdr *sechd
return 0;
}
-int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
flush_cache_all();
return 0;
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -854,10 +854,10 @@ deregister_unwind_table(struct module *m
unwind_table_remove(me->arch.unwind);
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
int i;
unsigned long nsyms;
const char *strtab = NULL;
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -31,9 +31,10 @@ static const Elf_Shdr *find_section(cons
return NULL;
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs, struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *sect;
int rc;
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -437,10 +437,10 @@ int apply_relocate_add(Elf_Shdr *sechdrs
return 0;
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *s;
char *secstrings, *secname;
void *aseg;
--- a/arch/sh/kernel/module.c
+++ b/arch/sh/kernel/module.c
@@ -96,10 +96,10 @@ int apply_relocate_add(Elf32_Shdr *sechd
return 0;
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
int ret = 0;
ret |= module_dwarf_finalize(hdr, sechdrs, me);
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -204,10 +204,11 @@ static void do_patch_sections(const Elf_
}
}
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
+
/* make jump label nops */
jump_label_apply_nops(me);
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -217,10 +217,10 @@ int apply_relocate_add(Elf64_Shdr *sechd
}
#endif
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int module_finalize(const struct load_info *info, struct module *me)
{
+ const Elf_Ehdr *hdr = info->hdr;
+ const Elf_Shdr *sechdrs = info->sechdrs;
const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
*para = NULL, *orc = NULL, *orc_ip = NULL;
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -101,9 +101,7 @@ static inline int apply_relocate_add(Elf
#endif
/* Any final processing of module before access. Return -error or 0. */
-int module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *mod);
+int module_finalize(const struct load_info *info, struct module *mod);
/* Any cleanup needed when module leaves. */
void module_arch_cleanup(struct module *mod);
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3425,9 +3425,7 @@ static void module_deallocate(struct mod
module_memfree(mod->core_layout.base);
}
-int __weak module_finalize(const Elf_Ehdr *hdr,
- const Elf_Shdr *sechdrs,
- struct module *me)
+int __weak module_finalize(const struct load_info *info, struct module *me)
{
return 0;
}
@@ -3445,7 +3443,7 @@ static int post_relocation(struct module
add_kallsyms(mod, info);
/* Arch-specific module finalizing. */
- return module_finalize(info->hdr, info->sechdrs, mod);
+ return module_finalize(info, mod);
}
/* Is this module of this name done loading? No locks held. */
next prev parent reply other threads:[~2020-04-07 11:13 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 11:02 [PATCH 0/4] x86/module: Out-of-tree module decode and sanitize Peter Zijlstra
2020-04-07 11:02 ` [PATCH 1/4] module: Expose load_info to arch module loader code Peter Zijlstra
2020-04-07 16:52 ` Kees Cook
2020-04-07 11:02 ` Peter Zijlstra [this message]
2020-04-07 16:53 ` [PATCH 2/4] module: Convert module_finalize() to load_info Kees Cook
2020-04-07 11:02 ` [PATCH 3/4] x86,module: Detect VMX vs SLD conflicts Peter Zijlstra
2020-04-07 14:35 ` Greg KH
2020-04-07 14:44 ` Paolo Bonzini
2020-04-07 14:55 ` Greg KH
2020-04-07 14:49 ` Steven Rostedt
2020-04-07 15:24 ` Peter Zijlstra
2020-04-07 15:28 ` Paolo Bonzini
2020-04-07 15:44 ` Greg KH
2020-04-07 16:51 ` Masami Hiramatsu
2020-04-07 17:16 ` Andrew Cooper
2020-04-07 23:59 ` Masami Hiramatsu
2020-04-08 7:25 ` Masami Hiramatsu
2020-04-07 18:26 ` kbuild test robot
2020-04-07 21:25 ` David Laight
2020-04-07 23:15 ` Kees Cook
2020-04-08 2:10 ` Xiaoyao Li
2020-04-08 8:09 ` Masami Hiramatsu
2020-04-08 9:56 ` Peter Zijlstra
2020-04-08 10:15 ` Andrew Cooper
2020-04-10 11:25 ` Masami Hiramatsu
2020-04-07 11:02 ` [PATCH 4/4] x86,module: Detect CRn and DRn manipulation Peter Zijlstra
2020-04-07 17:01 ` Kees Cook
2020-04-07 18:13 ` Peter Zijlstra
2020-04-07 18:49 ` Kees Cook
2020-04-07 18:55 ` Nadav Amit
2020-04-07 19:38 ` Peter Zijlstra
2020-04-07 20:27 ` Nadav Amit
2020-04-07 20:50 ` Peter Zijlstra
2020-04-07 21:22 ` Nadav Amit
2020-04-07 21:27 ` Peter Zijlstra
2020-04-07 22:12 ` Paolo Bonzini
2020-04-07 23:51 ` Nadav Amit
2020-04-08 8:45 ` Peter Zijlstra
2020-04-08 5:18 ` Christoph Hellwig
2020-04-07 23:15 ` Andrew Cooper
2020-04-08 0:22 ` Paolo Bonzini
2020-04-08 8:37 ` Peter Zijlstra
2020-04-08 9:52 ` Andrew Cooper
2020-04-07 21:48 ` Steven Rostedt
2020-04-08 5:58 ` Jan Kiszka
2020-04-08 8:03 ` Paolo Bonzini
2020-04-08 8:58 ` Jan Kiszka
2020-04-08 9:04 ` Paolo Bonzini
2020-04-08 10:45 ` Jan Kiszka
2020-04-08 8:51 ` Peter Zijlstra
2020-04-08 8:59 ` Jan Kiszka
2020-04-08 9:25 ` David Laight
2020-04-08 11:13 ` Jan Kiszka
2020-04-08 11:17 ` David Laight
2020-04-08 9:13 ` Peter Zijlstra
2020-04-08 10:50 ` Jan Kiszka
2020-04-08 13:27 ` Steven Rostedt
2020-04-08 15:44 ` Peter Zijlstra
2020-04-08 15:46 ` Christoph Hellwig
2020-04-08 16:02 ` Sean Christopherson
2020-04-08 16:15 ` Paolo Bonzini
2020-04-09 8:56 ` Peter Zijlstra
2020-04-09 10:13 ` Nadav Amit
2020-04-09 21:13 ` Thomas Gleixner
2020-04-09 22:18 ` Steven Rostedt
2020-04-10 5:37 ` Nadav Amit
2020-04-08 15:54 ` Jessica Yu
2020-04-07 17:23 ` [PATCH 0/4] x86/module: Out-of-tree module decode and sanitize Andrew Cooper
2020-04-07 19:41 ` Peter Zijlstra
2020-04-07 20:11 ` Andrew Cooper
2020-04-07 20:45 ` Peter Zijlstra
2020-04-07 21:21 ` Andrew Cooper
2020-04-07 20:21 ` Andrew Cooper
2020-04-07 20:48 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200407111007.276421550@infradead.org \
--to=peterz@infradead.org \
--cc=David.Laight@aculab.com \
--cc=bp@alien8.de \
--cc=dcovelli@vmware.com \
--cc=fenghua.yu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=kenny@panix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=nadav.amit@gmail.com \
--cc=pbonzini@redhat.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=rostedt@goodmis.org \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=thellstrom@vmware.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox