[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240105062007.26965-1-mengjingzi@iie.ac.cn>
Date: Fri, 5 Jan 2024 14:20:07 +0800
From: Jingzi Meng <mengjingzi@....ac.cn>
To: gregkh@...uxfoundation.org
Cc: gpiccoli@...lia.com,
john.ogness@...utronix.de,
keescook@...omium.org,
linux-hardening@...r.kernel.org,
linux-kernel@...r.kernel.org,
pmladek@...e.com,
rostedt@...dmis.org,
senozhatsky@...omium.org,
tony.luck@...el.com
Subject: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
CAP_SYSLOG was separated from CAP_SYS_ADMIN and introduced in Linux
2.6.37 (2010-11). For a long time, certain syslog actions required
CAP_SYS_ADMIN or CAP_SYSLOG. Maybe it’s time to officially remove
CAP_SYS_ADMIN for more fine-grained control.
CAP_SYS_ADMIN was once removed but added back for backwards
compatibility reasons. In commit 38ef4c2e437d ("syslog: check cap_syslog
when dmesg_restrict") (2010-12), CAP_SYS_ADMIN was no longer needed. And
in commit ee24aebffb75 ("cap_syslog: accept CAP_SYS_ADMIN for now")
(2011-02), it was accepted again. Since then, CAP_SYS_ADMIN has been
preserved.
Now that almost 13 years have passed, the legacy application may have
had enough time to be updated.
Signed-off-by: Jingzi Meng <mengjingzi@....ac.cn>
---
In addition, we examined the kernel code and identified that the user api
affected by this change is the syslog system call, which we tested on
the patched kernel to make sure the effect is as expected.
kernel/printk/printk.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index be95a6851164..6e1153d7de21 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -598,17 +598,6 @@ static int check_syslog_permissions(int type, int source)
if (syslog_action_restricted(type)) {
if (capable(CAP_SYSLOG))
goto ok;
- /*
- * For historical reasons, accept CAP_SYS_ADMIN too, with
- * a warning.
- */
- if (capable(CAP_SYS_ADMIN)) {
- pr_warn_once("%s (%d): Attempt to access syslog with "
- "CAP_SYS_ADMIN but no CAP_SYSLOG "
- "(deprecated).\n",
- current->comm, task_pid_nr(current));
- goto ok;
- }
return -EPERM;
}
ok:
--
2.20.1
Powered by blists - more mailing lists