Skip to content

Commit dbd9d6f

Browse files
AgentDtorvalds
authored andcommitted
fs/coredump.c: log if a core dump is aborted due to changed file permissions
For obvious security reasons, a core dump is aborted if the filesystem cannot preserve ownership or permissions of the dump file. This affects filesystems like e.g. vfat, but also something like a 9pfs share in a Qemu test setup, running as a regular user, depending on the security model used. In those cases, the result is an empty core file and a confused user. To hopefully save other people a lot of time figuring out the cause, this patch adds a simple log message for those specific cases. [[email protected]: s/|%s/%s/ in printk text] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Oberhollenzer <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 98e2e40 commit dbd9d6f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/coredump.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,17 @@ void do_coredump(const kernel_siginfo_t *siginfo)
782782
* filesystem.
783783
*/
784784
mnt_userns = file_mnt_user_ns(cprm.file);
785-
if (!uid_eq(i_uid_into_mnt(mnt_userns, inode), current_fsuid()))
785+
if (!uid_eq(i_uid_into_mnt(mnt_userns, inode),
786+
current_fsuid())) {
787+
pr_info_ratelimited("Core dump to %s aborted: cannot preserve file owner\n",
788+
cn.corename);
786789
goto close_fail;
787-
if ((inode->i_mode & 0677) != 0600)
790+
}
791+
if ((inode->i_mode & 0677) != 0600) {
792+
pr_info_ratelimited("Core dump to %s aborted: cannot preserve file permissions\n",
793+
cn.corename);
788794
goto close_fail;
795+
}
789796
if (!(cprm.file->f_mode & FMODE_CAN_WRITE))
790797
goto close_fail;
791798
if (do_truncate(mnt_userns, cprm.file->f_path.dentry,

0 commit comments

Comments
 (0)