Skip to content

Commit

Permalink
Minimal support for execveat(AT_FDCWD)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbednarski committed May 13, 2023
1 parent f30ce3e commit 2d7c70e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/syscall/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <sys/prctl.h> /* PR_SET_DUMPABLE */
#include <termios.h> /* TCSETS, TCSANOW */

#include "cli/note.h"
#include "syscall/syscall.h"
#include "syscall/sysnum.h"
#include "syscall/socket.h"
Expand Down Expand Up @@ -127,6 +128,20 @@ int translate_syscall_enter(Tracee *tracee)
status = translate_execve_enter(tracee);
break;

case PR_execveat:
if ((int) peek_reg(tracee, CURRENT, SYSARG_1) == AT_FDCWD) {
set_sysnum(tracee, PR_execve);
poke_reg(tracee, SYSARG_1, peek_reg(tracee, CURRENT, SYSARG_2));
poke_reg(tracee, SYSARG_2, peek_reg(tracee, CURRENT, SYSARG_3));
poke_reg(tracee, SYSARG_3, peek_reg(tracee, CURRENT, SYSARG_4));
} else {
note(tracee, ERROR, SYSTEM, "execveat() with non-AT_FDCWD fd is not currently supported");
status = -ENOSYS;
break;
}
status = translate_execve_enter(tracee);
break;

case PR_ptrace:
status = translate_ptrace_enter(tracee);
break;
Expand Down
1 change: 1 addition & 0 deletions src/syscall/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ static FilteredSysnum proot_sysnums[] = {
{ PR_connect, 0 },
{ PR_creat, 0 },
{ PR_execve, FILTER_SYSEXIT },
{ PR_execveat, 0 },
{ PR_faccessat, 0 },
{ PR_faccessat2, 0 },
{ PR_fchdir, FILTER_SYSEXIT },
Expand Down

0 comments on commit 2d7c70e

Please sign in to comment.