From: Maninder Singh <maninder1.s@samsung.com>
To: mcgrof@kernel.org, pmladek@suse.com, rostedt@goodmis.org,
senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com,
akpm@linux-foundation.org, wangkefeng.wang@huawei.com,
wedsonaf@google.com, boqun.feng@gmail.com,
christophe.leroy@csgroup.eu
Cc: swboyd@chromium.org, ojeda@kernel.org, ast@kernel.org,
gary@garyguo.net, mbenes@suse.cz, ndesaulniers@google.com,
void@manifault.com, jolsa@kernel.org,
linux-kernel@vger.kernel.org, v.narang@samsung.com,
Maninder Singh <maninder1.s@samsung.com>,
Onkarnath <onkarnath.1@samsung.com>
Subject: [PATCH 1/1] kallsyms: add kallsyms_show_value definition in all cases
Date: Wed, 13 Apr 2022 11:23:05 +0530 [thread overview]
Message-ID: <20220413055305.1768223-1-maninder1.s@samsung.com> (raw)
In-Reply-To: <CGME20220413055318epcas5p3df3cdde54a559d4002a74de9f23289f2@epcas5p3.samsung.com>
kallsyms_show_value return false if KALLSYMS is disabled,
but it's used in module.c also.
Thus when KALLSYMS is disabled, system will not print module
load address:
/ # insmod crash.ko
/ # lsmod
crash 12288 0 - Live 0x0000000000000000 (O)
After change (making definition generic)
============
/ # lsmod
crash 12288 0 - Live 0xffff800000ec0000 (O)
/ # cat /proc/modules
crash 12288 0 - Live 0xffff800000ec0000 (O)
/ #
Co-developed-by: Onkarnath <onkarnath.1@samsung.com>
Signed-off-by: Onkarnath <onkarnath.1@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
include/linux/kallsyms.h | 11 +++--------
kernel/kallsyms.c | 35 -----------------------------------
lib/vsprintf.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 43 deletions(-)
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index e5ad6e31697d..efabb8c18492 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -24,6 +24,9 @@
struct cred;
struct module;
+/* How and when do we show kallsyms values? */
+extern bool kallsyms_show_value(const struct cred *cred);
+
static inline int is_kernel_text(unsigned long addr)
{
if (__is_kernel_text(addr))
@@ -93,9 +96,6 @@ extern int sprint_backtrace_build_id(char *buffer, unsigned long address);
int lookup_symbol_name(unsigned long addr, char *symname);
int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
-/* How and when do we show kallsyms values? */
-extern bool kallsyms_show_value(const struct cred *cred);
-
#else /* !CONFIG_KALLSYMS */
static inline unsigned long kallsyms_lookup_name(const char *name)
@@ -158,11 +158,6 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
return -ERANGE;
}
-static inline bool kallsyms_show_value(const struct cred *cred)
-{
- return false;
-}
-
#endif /*CONFIG_KALLSYMS*/
static inline void print_ip_sym(const char *loglvl, unsigned long ip)
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index e8d2262ef2d2..71ef15ba20c7 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -818,41 +818,6 @@ static const struct seq_operations kallsyms_op = {
.show = s_show
};
-static inline int kallsyms_for_perf(void)
-{
-#ifdef CONFIG_PERF_EVENTS
- extern int sysctl_perf_event_paranoid;
- if (sysctl_perf_event_paranoid <= 1)
- return 1;
-#endif
- return 0;
-}
-
-/*
- * We show kallsyms information even to normal users if we've enabled
- * kernel profiling and are explicitly not paranoid (so kptr_restrict
- * is clear, and sysctl_perf_event_paranoid isn't set).
- *
- * Otherwise, require CAP_SYSLOG (assuming kptr_restrict isn't set to
- * block even that).
- */
-bool kallsyms_show_value(const struct cred *cred)
-{
- switch (kptr_restrict) {
- case 0:
- if (kallsyms_for_perf())
- return true;
- fallthrough;
- case 1:
- if (security_capable(cred, &init_user_ns, CAP_SYSLOG,
- CAP_OPT_NOAUDIT) == 0)
- return true;
- fallthrough;
- default:
- return false;
- }
-}
-
static int kallsyms_open(struct inode *inode, struct file *file)
{
/*
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 49ef55ffabd7..4bc96a4f3a00 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -870,6 +870,42 @@ static char *default_pointer(char *buf, char *end, const void *ptr,
int kptr_restrict __read_mostly;
+static inline int kallsyms_for_perf(void)
+{
+#ifdef CONFIG_PERF_EVENTS
+ extern int sysctl_perf_event_paranoid;
+
+ if (sysctl_perf_event_paranoid <= 1)
+ return 1;
+#endif
+ return 0;
+}
+
+/*
+ * We show kallsyms information even to normal users if we've enabled
+ * kernel profiling and are explicitly not paranoid (so kptr_restrict
+ * is clear, and sysctl_perf_event_paranoid isn't set).
+ *
+ * Otherwise, require CAP_SYSLOG (assuming kptr_restrict isn't set to
+ * block even that).
+ */
+bool kallsyms_show_value(const struct cred *cred)
+{
+ switch (kptr_restrict) {
+ case 0:
+ if (kallsyms_for_perf())
+ return true;
+ fallthrough;
+ case 1:
+ if (security_capable(cred, &init_user_ns, CAP_SYSLOG,
+ CAP_OPT_NOAUDIT) == 0)
+ return true;
+ fallthrough;
+ default:
+ return false;
+ }
+}
+
static noinline_for_stack
char *restricted_pointer(char *buf, char *end, const void *ptr,
struct printf_spec spec)
--
2.17.1
next parent reply other threads:[~2022-04-13 5:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220413055318epcas5p3df3cdde54a559d4002a74de9f23289f2@epcas5p3.samsung.com>
2022-04-13 5:53 ` Maninder Singh [this message]
2022-04-13 9:24 ` Petr Mladek
[not found] ` <CGME20220413055318epcas5p3df3cdde54a559d4002a74de9f23289f2@epcms5p5>
2022-04-18 4:34 ` Maninder Singh
2022-04-20 11:00 ` Petr Mladek
2022-04-20 15:21 ` Luis Chamberlain
2022-04-27 12:31 ` Vimal Agrawal
[not found] ` <CGME20220413055318epcas5p3df3cdde54a559d4002a74de9f23289f2@epcms5p7>
2022-05-07 5:49 ` Maninder Singh
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=20220413055305.1768223-1-maninder1.s@samsung.com \
--to=maninder1.s@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ast@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=christophe.leroy@csgroup.eu \
--cc=gary@garyguo.net \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=onkarnath.1@samsung.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=swboyd@chromium.org \
--cc=v.narang@samsung.com \
--cc=void@manifault.com \
--cc=wangkefeng.wang@huawei.com \
--cc=wedsonaf@google.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
all inboxes | Powered by JetHome®