summaryrefslogtreecommitdiff
path: root/fs/coredump.c
diff options
context:
space:
mode:
authorJann Horn <jann@thejh.net>2015-09-09 15:38:30 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 13:29:01 -0700
commit40f705a736eac10e7dca7ab5dd5ed675a6df031d (patch)
tree80ad7ecf85ece7a46133fd23b150d05a4074da5a /fs/coredump.c
parentfbb1816942c04429e85dbf4c1a080accc534299e (diff)
downloadlinux-rpi3-40f705a736eac10e7dca7ab5dd5ed675a6df031d.tar.gz
linux-rpi3-40f705a736eac10e7dca7ab5dd5ed675a6df031d.tar.bz2
linux-rpi3-40f705a736eac10e7dca7ab5dd5ed675a6df031d.zip
fs: Don't dump core if the corefile would become world-readable.
On a filesystem like vfat, all files are created with the same owner and mode independent of who created the file. When a vfat filesystem is mounted with root as owner of all files and read access for everyone, root's processes left world-readable coredumps on it (but other users' processes only left empty corefiles when given write access because of the uid mismatch). Given that the old behavior was inconsistent and insecure, I don't see a problem with changing it. Now, all processes refuse to dump core unless the resulting corefile will only be readable by their owner. Signed-off-by: Jann Horn <jann@thejh.net> Acked-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r--fs/coredump.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index b696dc2c220d..a8f75640ac86 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -685,11 +685,15 @@ void do_coredump(const siginfo_t *siginfo)
if (!S_ISREG(inode->i_mode))
goto close_fail;
/*
- * Dont allow local users get cute and trick others to coredump
- * into their pre-created files.
+ * Don't dump core if the filesystem changed owner or mode
+ * of the file during file creation. This is an issue when
+ * a process dumps core while its cwd is e.g. on a vfat
+ * filesystem.
*/
if (!uid_eq(inode->i_uid, current_fsuid()))
goto close_fail;
+ if ((inode->i_mode & 0677) != 0600)
+ goto close_fail;
if (!(cprm.file->f_mode & FMODE_CAN_WRITE))
goto close_fail;
if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file))