Skip to content

Commit

Permalink
Prevent tracees from becoming undumpable
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbednarski committed Sep 5, 2019
1 parent 0c2da81 commit 3ea655b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/syscall/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <fcntl.h> /* AT_FDCWD, */
#include <limits.h> /* PATH_MAX, */
#include <string.h> /* strcpy */
#include <sys/prctl.h> /* PR_SET_DUMPABLE */

#include "syscall/syscall.h"
#include "syscall/sysnum.h"
Expand Down Expand Up @@ -566,6 +567,15 @@ int translate_syscall_enter(Tracee *tracee)

status = translate_path2(tracee, newdirfd, newpath, SYSARG_3, SYMLINK);
break;

case PR_prctl:
/* Prevent tracees from setting dumpable flag.
* (Otherwise it could break tracee memory access) */
if (peek_reg(tracee, CURRENT, SYSARG_1) == PR_SET_DUMPABLE) {
set_sysnum(tracee, PR_void);
status = 0;
}
break;
}

end:
Expand Down
1 change: 1 addition & 0 deletions src/syscall/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ static FilteredSysnum proot_sysnums[] = {
{ PR_open, 0 },
{ PR_openat, 0 },
{ PR_pivot_root, 0 },
{ PR_prctl, 0 },
{ PR_prlimit64, FILTER_SYSEXIT },
{ PR_ptrace, FILTER_SYSEXIT },
{ PR_readlink, FILTER_SYSEXIT },
Expand Down

0 comments on commit 3ea655b

Please sign in to comment.