mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
coredump: warn about unsafe suid_dumpable / core_pattern combo
When suid_dumpable=2, detect unsafe core_pattern settings and warn when they are seen. Signed-off-by: Kees Cook <[email protected]> Suggested-by: Andrew Morton <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Alan Cox <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Doug Ledford <[email protected]> Cc: Serge Hallyn <[email protected]> Cc: James Morris <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
9520628e8c
commit
54b501992d
3 changed files with 45 additions and 7 deletions
10
fs/exec.c
10
fs/exec.c
|
|
@ -2002,17 +2002,17 @@ static void coredump_finish(struct mm_struct *mm)
|
|||
void set_dumpable(struct mm_struct *mm, int value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
case SUID_DUMPABLE_DISABLED:
|
||||
clear_bit(MMF_DUMPABLE, &mm->flags);
|
||||
smp_wmb();
|
||||
clear_bit(MMF_DUMP_SECURELY, &mm->flags);
|
||||
break;
|
||||
case 1:
|
||||
case SUID_DUMPABLE_ENABLED:
|
||||
set_bit(MMF_DUMPABLE, &mm->flags);
|
||||
smp_wmb();
|
||||
clear_bit(MMF_DUMP_SECURELY, &mm->flags);
|
||||
break;
|
||||
case 2:
|
||||
case SUID_DUMPABLE_SAFE:
|
||||
set_bit(MMF_DUMP_SECURELY, &mm->flags);
|
||||
smp_wmb();
|
||||
set_bit(MMF_DUMPABLE, &mm->flags);
|
||||
|
|
@ -2025,7 +2025,7 @@ static int __get_dumpable(unsigned long mm_flags)
|
|||
int ret;
|
||||
|
||||
ret = mm_flags & MMF_DUMPABLE_MASK;
|
||||
return (ret >= 2) ? 2 : ret;
|
||||
return (ret > SUID_DUMPABLE_ENABLED) ? SUID_DUMPABLE_SAFE : ret;
|
||||
}
|
||||
|
||||
int get_dumpable(struct mm_struct *mm)
|
||||
|
|
@ -2142,7 +2142,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|||
* so we dump it as root in mode 2, and only into a controlled
|
||||
* environment (pipe handler or fully qualified path).
|
||||
*/
|
||||
if (__get_dumpable(cprm.mm_flags) == 2) {
|
||||
if (__get_dumpable(cprm.mm_flags) == SUID_DUMPABLE_SAFE) {
|
||||
/* Setuid core dump mode */
|
||||
flag = O_EXCL; /* Stop rewrite attacks */
|
||||
cred->fsuid = GLOBAL_ROOT_UID; /* Dump root private */
|
||||
|
|
|
|||
Loading…
Reference in a new issue