aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pstore
diff options
context:
space:
mode:
authorSebastian Schmidt <yath@yath.de>2014-10-19 14:05:15 -0400
committerTony Luck <tony.luck@intel.com>2014-11-05 12:59:48 -0500
commit68c4a4f8abc60c9440ede9cd123d48b78325f7a3 (patch)
treeef8aefb7d8c3769204116ff65cfa48551464a275 /fs/pstore
parenta28726b4fb624f81d637a8afb9ea12fc16500f61 (diff)
pstore: Honor dmesg_restrict sysctl on dmesg dumps
When the kernel.dmesg_restrict restriction is in place, only users with CAP_SYSLOG should be able to access crash dumps (like: attacker is trying to exploit a bug, watchdog reboots, attacker can happily read crash dumps and logs). This puts the restriction on console-* types as well as sensitive information could have been leaked there. Other log types are unaffected. Signed-off-by: Sebastian Schmidt <yath@yath.de> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/inode.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index fafb7a02a5d6..50416602774d 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -36,6 +36,7 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39#include <linux/syslog.h>
39 40
40#include "internal.h" 41#include "internal.h"
41 42
@@ -120,6 +121,18 @@ static const struct seq_operations pstore_ftrace_seq_ops = {
120 .show = pstore_ftrace_seq_show, 121 .show = pstore_ftrace_seq_show,
121}; 122};
122 123
124static int pstore_check_syslog_permissions(struct pstore_private *ps)
125{
126 switch (ps->type) {
127 case PSTORE_TYPE_DMESG:
128 case PSTORE_TYPE_CONSOLE:
129 return check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
130 SYSLOG_FROM_READER);
131 default:
132 return 0;
133 }
134}
135
123static ssize_t pstore_file_read(struct file *file, char __user *userbuf, 136static ssize_t pstore_file_read(struct file *file, char __user *userbuf,
124 size_t count, loff_t *ppos) 137 size_t count, loff_t *ppos)
125{ 138{
@@ -138,6 +151,10 @@ static int pstore_file_open(struct inode *inode, struct file *file)
138 int err; 151 int err;
139 const struct seq_operations *sops = NULL; 152 const struct seq_operations *sops = NULL;
140 153
154 err = pstore_check_syslog_permissions(ps);
155 if (err)
156 return err;
157
141 if (ps->type == PSTORE_TYPE_FTRACE) 158 if (ps->type == PSTORE_TYPE_FTRACE)
142 sops = &pstore_ftrace_seq_ops; 159 sops = &pstore_ftrace_seq_ops;
143 160
@@ -174,6 +191,11 @@ static const struct file_operations pstore_file_operations = {
174static int pstore_unlink(struct inode *dir, struct dentry *dentry) 191static int pstore_unlink(struct inode *dir, struct dentry *dentry)
175{ 192{
176 struct pstore_private *p = dentry->d_inode->i_private; 193 struct pstore_private *p = dentry->d_inode->i_private;
194 int err;
195
196 err = pstore_check_syslog_permissions(p);
197 if (err)
198 return err;
177 199
178 if (p->psi->erase) 200 if (p->psi->erase)
179 p->psi->erase(p->type, p->id, p->count, 201 p->psi->erase(p->type, p->id, p->count,