public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] /proc/modules: honor kptr_restrict even without CONFIG_KALLSYMS
@ 2022-06-05 20:43 Aleksander Mazur
  2023-05-26 22:55 ` Aleksander Mazur
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksander Mazur @ 2022-06-05 20:43 UTC (permalink / raw)
  To: Arnd Bergmann, Sergey Senozhatsky
  Cc: Aleksander Mazur, linux-kernel, Jiri Olsa

Commit e4a8ca3baa55 fixed building without CONFIG_KALLSYMS by providing
dummy kallsyms_show_value(). Unfortunately -- due to hard-coded "false"
being returned -- access to addresses in /proc/modules became permanently
disabled.

My proposal is to change this unconditional "false" to !kptr_restrict.
This re-enables addresses in /proc/modules even without CONFIG_KALLSYSMS
unless restricted by means of sysctl (kernel.kptr_restrict).

Fixes: e4a8ca3baa55 ("/proc/module: fix building without kallsyms")
Signed-off-by: Aleksander Mazur <deweloper@wp.pl>
---
 include/linux/kallsyms.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index ad39636e0c3f..cf64f9709f46 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -160,7 +160,7 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
 
 static inline bool kallsyms_show_value(const struct cred *cred)
 {
-	return false;
+	return !kptr_restrict;
 }
 
 static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-21 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-05 20:43 [PATCH] /proc/modules: honor kptr_restrict even without CONFIG_KALLSYMS Aleksander Mazur
2023-05-26 22:55 ` Aleksander Mazur
2023-05-27  9:44   ` Arnd Bergmann
2023-08-21 15:13     ` Aleksander Mazur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox