aboutsummaryrefslogtreecommitdiff
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2010-11-29 08:27:07 +1100
committerJames Morris <jmorris@namei.org>2010-11-29 08:27:07 +1100
commit1d6d75684d869406e5bb2ac5d3ed9454f52d0cab (patch)
treeafb229254bed6415407b7b7d4641f9f792109966 /kernel/printk.c
parent074e61ec3751da9ab88ee66d3818574556c03489 (diff)
parent0f639a3c5ca63dd76ee07de9b02ebf0178ce9a17 (diff)
Merge branch 'master' into next
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index b2ebaee8c37..9a2264fc42c 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -261,6 +261,12 @@ static inline void boot_delay_msec(void)
}
#endif
+#ifdef CONFIG_SECURITY_DMESG_RESTRICT
+int dmesg_restrict = 1;
+#else
+int dmesg_restrict;
+#endif
+
int do_syslog(int type, char __user *buf, int len, bool from_file)
{
unsigned i, j, limit, count;
@@ -268,7 +274,20 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
char c;
int error = 0;
- error = security_syslog(type, from_file);
+ /*
+ * If this is from /proc/kmsg we only do the capabilities checks
+ * at open time.
+ */
+ if (type == SYSLOG_ACTION_OPEN || !from_file) {
+ if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ if ((type != SYSLOG_ACTION_READ_ALL &&
+ type != SYSLOG_ACTION_SIZE_BUFFER) &&
+ !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ }
+
+ error = security_syslog(type);
if (error)
return error;