summaryrefslogtreecommitdiff
path: root/kernel/module
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-10-09 21:45:17 +0200
committerMark Brown <broonie@kernel.org>2026-10-09 21:45:17 +0200
commit868fe88393e06ab52b60dcb7434ed6bbcf2e0f32 (patch)
tree08f10b0d7a4a0d963b3029079e43240497aa41ce /kernel/module
parentf9869238f853642e9f1760b1fa9feae7724f1ea4 (diff)
parentff7360c5c731356a59171eef732a26a72381a8ba (diff)
downloadlinux-next-868fe88393e06ab52b60dcb7434ed6bbcf2e0f32.tar.gz
linux-next-868fe88393e06ab52b60dcb7434ed6bbcf2e0f32.zip
Merge branch 'modules-next' of https://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git
Diffstat (limited to 'kernel/module')
-rw-r--r--kernel/module/kallsyms.c59
-rw-r--r--kernel/module/kmod.c3
-rw-r--r--kernel/module/main.c1
3 files changed, 34 insertions, 29 deletions
diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
index f23126d804b2..1ff8ce857d92 100644
--- a/kernel/module/kallsyms.c
+++ b/kernel/module/kallsyms.c
@@ -75,23 +75,29 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info)
return '?';
}
-static bool is_core_symbol(const Elf_Sym *src, const Elf_Shdr *sechdrs,
- unsigned int shnum, unsigned int pcpundx)
+static bool is_core_symbol(struct module *mod, const struct load_info *info,
+ unsigned int symnum, const Elf_Sym *src)
{
const Elf_Shdr *sec;
enum mod_mem_type type;
+ if (symnum == 0 || is_livepatch_module(mod))
+ return true;
+
if (src->st_shndx == SHN_UNDEF ||
- src->st_shndx >= shnum ||
+ src->st_shndx >= info->hdr->e_shnum ||
!src->st_name)
return false;
+ if (is_ignored_kernel_symbol(&info->strtab[src->st_name]))
+ return false;
+
#ifdef CONFIG_KALLSYMS_ALL
- if (src->st_shndx == pcpundx)
+ if (src->st_shndx == info->index.pcpu)
return true;
#endif
- sec = sechdrs + src->st_shndx;
+ sec = info->sechdrs + src->st_shndx;
type = sec->sh_entsize >> SH_ENTSIZE_TYPE_SHIFT;
if (!(sec->sh_flags & SHF_ALLOC)
#ifndef CONFIG_KALLSYMS_ALL
@@ -130,12 +136,11 @@ void layout_symtab(struct module *mod, struct load_info *info)
/* Compute total space required for the core symbols' strtab. */
for (ndst = i = 0; i < nsrc; i++) {
- if (i == 0 || is_livepatch_module(mod) ||
- is_core_symbol(src + i, info->sechdrs, info->hdr->e_shnum,
- info->index.pcpu)) {
- strtab_size += strlen(&info->strtab[src[i].st_name]) + 1;
- ndst++;
- }
+ if (!is_core_symbol(mod, info, i, src + i))
+ continue;
+
+ strtab_size += strlen(&info->strtab[src[i].st_name]) + 1;
+ ndst++;
}
/* Append room for core symbols at end of core part. */
@@ -197,23 +202,21 @@ void add_kallsyms(struct module *mod, const struct load_info *info)
strtab_size = info->core_typeoffs - info->stroffs;
src = kallsyms->symtab;
for (ndst = i = 0; i < kallsyms->num_symtab; i++) {
+ ssize_t ret;
+
kallsyms->typetab[i] = elf_type(src + i, info);
- if (i == 0 || is_livepatch_module(mod) ||
- is_core_symbol(src + i, info->sechdrs, info->hdr->e_shnum,
- info->index.pcpu)) {
- ssize_t ret;
-
- mod->core_kallsyms.typetab[ndst] =
- kallsyms->typetab[i];
- dst[ndst] = src[i];
- dst[ndst++].st_name = s - mod->core_kallsyms.strtab;
- ret = strscpy(s, &kallsyms->strtab[src[i].st_name],
- strtab_size);
- if (ret < 0)
- break;
- s += ret + 1;
- strtab_size -= ret + 1;
- }
+
+ if (!is_core_symbol(mod, info, i, src + i))
+ continue;
+
+ mod->core_kallsyms.typetab[ndst] = kallsyms->typetab[i];
+ dst[ndst] = src[i];
+ dst[ndst++].st_name = s - mod->core_kallsyms.strtab;
+ ret = strscpy(s, &kallsyms->strtab[src[i].st_name], strtab_size);
+ if (ret < 0)
+ break;
+ s += ret + 1;
+ strtab_size -= ret + 1;
}
/* Set up to point into init section. */
@@ -294,7 +297,7 @@ static const char *find_kallsyms_symbol(struct module *mod,
* and inserted at a whim.
*/
if (*kallsyms_symbol_name(kallsyms, i) == '\0' ||
- is_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
+ is_ignored_kernel_symbol(kallsyms_symbol_name(kallsyms, i)))
continue;
if (thisval <= addr && thisval > bestval) {
diff --git a/kernel/module/kmod.c b/kernel/module/kmod.c
index a25dccdf7aa7..24091210741e 100644
--- a/kernel/module/kmod.c
+++ b/kernel/module/kmod.c
@@ -28,6 +28,7 @@
#include <linux/ptrace.h>
#include <linux/async.h>
#include <linux/uaccess.h>
+#include <linux/umh.h>
#include <trace/events/module.h>
#include "internal.h"
@@ -81,7 +82,7 @@ static int call_modprobe(char *orig_module_name, int wait)
char *module_name;
int ret;
- char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
+ char **argv = kmalloc_array(5, sizeof(*argv), GFP_KERNEL);
if (!argv)
goto out;
diff --git a/kernel/module/main.c b/kernel/module/main.c
index c1b34dc1e89a..91c4a507a38b 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -60,6 +60,7 @@
#include <linux/codetag.h>
#include <linux/debugfs.h>
#include <linux/execmem.h>
+#include <linux/error-injection.h>
#include <uapi/linux/module.h>
#include "internal.h"