All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksander Mazur <deweloper@wp.pl>
To: Arnd Bergmann <arnd@arndb.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Aleksander Mazur <deweloper@wp.pl>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>
Subject: [PATCH] /proc/modules: honor kptr_restrict even without CONFIG_KALLSYMS
Date: Sun, 5 Jun 2022 22:43:47 +0200	[thread overview]
Message-ID: <20220605224347.481e2fb4@mocarz> (raw)

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


             reply	other threads:[~2022-06-05 20:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-05 20:43 Aleksander Mazur [this message]
2023-05-26 22:55 ` [PATCH] /proc/modules: honor kptr_restrict even without CONFIG_KALLSYMS Aleksander Mazur
2023-05-27  9:44   ` Arnd Bergmann
2023-08-21 15:13     ` Aleksander Mazur

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=20220605224347.481e2fb4@mocarz \
    --to=deweloper@wp.pl \
    --cc=arnd@arndb.de \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.