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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 May 2022 13:36:57 +0530
From:   Maninder Singh <maninder1.s@...sung.com>
To:     mcgrof@...nel.org, avimalin@...il.com, ast@...nel.org,
        daniel@...earbox.net, andrii@...nel.org, kafai@...com,
        songliubraving@...com, yhs@...com, john.fastabend@...il.com,
        kpsingh@...nel.org, pmladek@...e.com, rostedt@...dmis.org,
        senozhatsky@...omium.org, andriy.shevchenko@...ux.intel.com,
        naveen.n.rao@...ux.ibm.com, davem@...emloft.net,
        mhiramat@...nel.org, anil.s.keshavamurthy@...el.com,
        linux@...musvillemoes.dk, akpm@...ux-foundation.org,
        keescook@...omium.org
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        v.narang@...sung.com, Maninder Singh <maninder1.s@...sung.com>,
        Onkarnath <onkarnath.1@...sung.com>
Subject: [PATCH 2/2] kallsyms: move sprint_module_info to kallsyms_tiny.c

As previous patch makes new file for generic kallsyms
(always compilable), move sprint_module_info module to
new file kallsyms_tiny.c

no functional change with this commit

Co-developed-by: Onkarnath <onkarnath.1@...sung.com>
Signed-off-by: Onkarnath <onkarnath.1@...sung.com>
Signed-off-by: Maninder Singh <maninder1.s@...sung.com>
---
 include/linux/kallsyms.h | 11 +++++++++
 kernel/kallsyms_tiny.c   | 47 +++++++++++++++++++++++++++++++++++
 lib/vsprintf.c           | 53 ----------------------------------------
 3 files changed, 58 insertions(+), 53 deletions(-)

diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index c5e63a217404..95a2f4ade996 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -27,6 +27,17 @@ struct module;
 /* How and when do we show kallsyms values? */
 extern bool kallsyms_show_value(const struct cred *cred);
 
+#if !defined(CONFIG_KALLSYMS) && defined(CONFIG_MODULES)
+extern int sprint_module_info(char *buf, unsigned long value,
+				int modbuildid, int backtrace, int symbol);
+#else
+static inline int sprint_module_info(char *buf, unsigned long value,
+				int modbuildid, int backtrace, int symbol)
+{
+	return 0;
+}
+#endif
+
 static inline int is_kernel_text(unsigned long addr)
 {
 	if (__is_kernel_text(addr))
diff --git a/kernel/kallsyms_tiny.c b/kernel/kallsyms_tiny.c
index 96ad06836126..8ed9fdd7d9f7 100644
--- a/kernel/kallsyms_tiny.c
+++ b/kernel/kallsyms_tiny.c
@@ -49,3 +49,50 @@ bool kallsyms_show_value(const struct cred *cred)
 		return false;
 	}
 }
+
+#if !defined(CONFIG_KALLSYMS) && defined(CONFIG_MODULES)
+int sprint_module_info(char *buf, unsigned long value,
+			     int modbuildid, int backtrace, int symbol)
+{
+	struct module *mod;
+	unsigned long offset;
+	void *base;
+	char *modname;
+	int len;
+	const unsigned char *buildid = NULL;
+	bool add_offset;
+
+	if (is_ksym_addr(value))
+		return 0;
+
+	if (backtrace || symbol)
+		add_offset = true;
+	else
+		add_offset = false;
+
+	preempt_disable();
+	mod = __module_address(value);
+	if (mod) {
+		modname = mod->name;
+#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
+		if (modbuildid)
+			buildid = mod->build_id;
+#endif
+		if (add_offset) {
+			base = mod->core_layout.base;
+			offset = value - (unsigned long)base;
+		}
+	}
+	preempt_enable();
+	if (!mod)
+		return 0;
+
+	/* address belongs to module */
+	if (add_offset)
+		len = sprintf(buf, "0x%p+0x%lx", base, offset);
+	else
+		len = sprintf(buf, "0x%lx", value);
+
+	return len + fill_name_build_id(buf, modname, modbuildid, buildid, len);
+}
+#endif
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 799fccca4a2d..983fdb02543c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -999,59 +999,6 @@ char *bdev_name(char *buf, char *end, struct block_device *bdev,
 }
 #endif
 
-#if !defined(CONFIG_KALLSYMS) && defined(CONFIG_MODULES)
-static int sprint_module_info(char *buf, unsigned long value,
-			     int modbuildid, int backtrace, int symbol)
-{
-	struct module *mod;
-	unsigned long offset;
-	void *base;
-	char *modname;
-	int len;
-	const unsigned char *buildid = NULL;
-	bool add_offset;
-
-	if (is_ksym_addr(value))
-		return 0;
-
-	if (backtrace || symbol)
-		add_offset = true;
-	else
-		add_offset = false;
-
-	preempt_disable();
-	mod = __module_address(value);
-	if (mod) {
-		modname = mod->name;
-#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
-		if (modbuildid)
-			buildid = mod->build_id;
-#endif
-		if (add_offset) {
-			base = mod->core_layout.base;
-			offset = value - (unsigned long)base;
-		}
-	}
-	preempt_enable();
-	if (!mod)
-		return 0;
-
-	/* address belongs to module */
-	if (add_offset)
-		len = sprintf(buf, "0x%p+0x%lx", base, offset);
-	else
-		len = sprintf(buf, "0x%lx", value);
-
-	return len + fill_name_build_id(buf, modname, modbuildid, buildid, len);
-}
-#else
-static inline int sprint_module_info(char *buf, unsigned long value,
-			     int modbuildid, int backtrace, int symbol)
-{
-	return 0;
-}
-#endif
-
 static noinline_for_stack
 char *symbol_string(char *buf, char *end, void *ptr,
 		    struct printf_spec spec, const char *fmt)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ