diff options
author | Ingo Molnar <mingo@kernel.org> | 2020-07-28 13:18:01 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2020-07-28 13:18:01 +0200 |
commit | e89d4ca1df630378bde3e36c42001b755b0044fe (patch) | |
tree | d953ccecb8365acab65d0075e674f7e9a9bd9880 /kernel/kallsyms.c | |
parent | x86/perf: Fix a typo (diff) | |
parent | Linux 5.8-rc7 (diff) | |
download | linux-e89d4ca1df630378bde3e36c42001b755b0044fe.tar.xz linux-e89d4ca1df630378bde3e36c42001b755b0044fe.zip |
Merge tag 'v5.8-rc7' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/kallsyms.c')
-rw-r--r-- | kernel/kallsyms.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 834bfdc43235..95cb74f73292 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -678,19 +678,20 @@ static inline int kallsyms_for_perf(void) * Otherwise, require CAP_SYSLOG (assuming kptr_restrict isn't set to * block even that). */ -int kallsyms_show_value(void) +bool kallsyms_show_value(const struct cred *cred) { switch (kptr_restrict) { case 0: if (kallsyms_for_perf()) - return 1; + return true; /* fallthrough */ case 1: - if (has_capability_noaudit(current, CAP_SYSLOG)) - return 1; + if (security_capable(cred, &init_user_ns, CAP_SYSLOG, + CAP_OPT_NOAUDIT) == 0) + return true; /* fallthrough */ default: - return 0; + return false; } } @@ -707,7 +708,11 @@ static int kallsyms_open(struct inode *inode, struct file *file) return -ENOMEM; reset_iter(iter, 0); - iter->show_value = kallsyms_show_value(); + /* + * Instead of checking this on every s_show() call, cache + * the result here at open time. + */ + iter->show_value = kallsyms_show_value(file->f_cred); return 0; } |