summaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2010-11-28 22:27:07 +0100
committerJames Morris <jmorris@namei.org>2010-11-28 22:27:07 +0100
commit1d6d75684d869406e5bb2ac5d3ed9454f52d0cab (patch)
treeafb229254bed6415407b7b7d4641f9f792109966 /kernel/printk.c
parentkernel: add roundup() code comment from akpm (diff)
parentMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiw... (diff)
downloadlinux-1d6d75684d869406e5bb2ac5d3ed9454f52d0cab.tar.xz
linux-1d6d75684d869406e5bb2ac5d3ed9454f52d0cab.zip
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 b2ebaee8c377..9a2264fc42ca 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;