lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1592993898-14307-1-git-send-email-vishal.goel@samsung.com>
Date:   Wed, 24 Jun 2020 15:48:18 +0530
From:   Vishal Goel <vishal.goel@...sung.com>
To:     rusty@...tcorp.com.au, linux-kernel@...r.kernel.org
Cc:     Vishal Goel <vishal.goel@...sung.com>,
        Amit Sahrawat <a.sahrawat@...sung.com>
Subject: [PATCH 1/1] Module:- Do not store unnecessary symbols for kernel
 modules

While loading modules, ignores the mapping symbols found in ARM
ELF files: $a, $t and $d.
Also ignores symbols starting with .L found in rodata.str sections
It will help in saving memory allocated for modules using
vmalloc.

It can save around 500KB - 1000KB depending on the number of
modules and number of symbols present in them

Signed-off-by: Vishal Goel <vishal.goel@...sung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@...sung.com>
---
 kernel/module.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 646f1e2..d5b7b0a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2550,6 +2550,20 @@ static void free_modinfo(struct module *mod)
 
 #ifdef CONFIG_KALLSYMS
 
+/*
+ * This ignores the intensely annoying "mapping symbols" found
+ * in ARM ELF files: $a, $t and $d.
+ * It also ignores symbols starting with .L found in rodata.str sections
+ */
+static inline int is_arm_mapping_symbol(const char *str)
+{
+	if (str[0] == '.' && str[1] == 'L')
+		return true;
+	return str[0] == '$' && strchr("axtd", str[1])
+		&& (str[2] == '\0' || str[2] == '.');
+}
+
+
 /* Lookup exported symbol in given range of kernel_symbols */
 static const struct kernel_symbol *lookup_exported_symbol(const char *name,
 							  const struct kernel_symbol *start,
@@ -2664,8 +2678,9 @@ static 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)) {
+		    (is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
+				   info->index.pcpu) &&
+		     !is_arm_mapping_symbol(&info->strtab[src[i].st_name]))) {
 			strtab_size += strlen(&info->strtab[src[i].st_name])+1;
 			ndst++;
 		}
@@ -2728,8 +2743,9 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
 	for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) {
 		mod->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)) {
+		    (is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
+				   info->index.pcpu) &&
+		     !is_arm_mapping_symbol(&info->strtab[src[i].st_name]))) {
 			mod->core_kallsyms.typetab[ndst] =
 			    mod->kallsyms->typetab[i];
 			dst[ndst] = src[i];
@@ -3986,17 +4002,6 @@ static inline int within(unsigned long addr, void *start, unsigned long size)
 }
 
 #ifdef CONFIG_KALLSYMS
-/*
- * This ignores the intensely annoying "mapping symbols" found
- * in ARM ELF files: $a, $t and $d.
- */
-static inline int is_arm_mapping_symbol(const char *str)
-{
-	if (str[0] == '.' && str[1] == 'L')
-		return true;
-	return str[0] == '$' && strchr("axtd", str[1])
-	       && (str[2] == '\0' || str[2] == '.');
-}
 
 static const char *kallsyms_symbol_name(struct mod_kallsyms *kallsyms, unsigned int symnum)
 {
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ