Skip to content

Commit

Permalink
Remove preprocessor directives and associated code,
Browse files Browse the repository at this point in the history
that tie runtime behavior to compilation environment,
which is the wrong thing to do.
  • Loading branch information
jzakrzew authored and oxr463 committed Sep 7, 2021
1 parent d5a796e commit 252a824
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/tracee/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ int handle_tracee_event_kernel_4_8(Tracee *tracee, int tracee_status)
int handle_tracee_event(Tracee *tracee, int tracee_status)
{
static bool seccomp_detected = false;
static bool seccomp_enabled = false;
long status;
int signal;

Expand Down Expand Up @@ -710,7 +709,6 @@ int handle_tracee_event(Tracee *tracee, int tracee_status)
status = ptrace(PTRACE_SETOPTIONS, tracee->pid, NULL,
default_ptrace_options | PTRACE_O_TRACESECCOMP);
if (status < 0) {
seccomp_enabled = false;
/* ... otherwise use default options only. */
status = ptrace(PTRACE_SETOPTIONS, tracee->pid, NULL,
default_ptrace_options);
Expand All @@ -719,50 +717,8 @@ int handle_tracee_event(Tracee *tracee, int tracee_status)
exit(EXIT_FAILURE);
}
}
else {
if (getenv("PROOT_NO_SECCOMP") == NULL)
seccomp_enabled = true;
}
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0)

/* Fall through. */
case SIGTRAP | PTRACE_EVENT_SECCOMP2 << 8:
case SIGTRAP | PTRACE_EVENT_SECCOMP << 8:

if (!seccomp_detected && seccomp_enabled) {
VERBOSE(tracee, 1, "ptrace acceleration (seccomp mode 2) enabled");
tracee->seccomp = ENABLED;
seccomp_detected = true;
}

if (signal == (SIGTRAP | PTRACE_EVENT_SECCOMP2 << 8) ||
signal == (SIGTRAP | PTRACE_EVENT_SECCOMP << 8)) {

unsigned long flags = 0;
signal = 0;

/* SECCOMP TRAP can only be received for
* sysenter events, ignore otherwise */
if (!IS_IN_SYSENTER(tracee)) {
tracee->restart_how = PTRACE_CONT;
return 0;
}
status = ptrace(PTRACE_GETEVENTMSG, tracee->pid, NULL, &flags);
if (status < 0)
break;

if (tracee->seccomp == ENABLED && (flags & FILTER_SYSEXIT) == 0) {
tracee->restart_how = PTRACE_CONT;
translate_syscall(tracee);

if (tracee->seccomp == DISABLING)
tracee->restart_how = PTRACE_SYSCALL;
break;
}
}
#endif
/* Fall through. */
case SIGTRAP | 0x80:
signal = 0;
Expand Down Expand Up @@ -812,8 +768,6 @@ int handle_tracee_event(Tracee *tracee, int tracee_status)
}
break;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)

case SIGTRAP | PTRACE_EVENT_SECCOMP2 << 8:
case SIGTRAP | PTRACE_EVENT_SECCOMP << 8: {
unsigned long flags = 0;
Expand Down Expand Up @@ -855,8 +809,6 @@ int handle_tracee_event(Tracee *tracee, int tracee_status)
break;
}

#endif

case SIGTRAP | PTRACE_EVENT_VFORK << 8:
signal = 0;
(void) new_child(tracee, CLONE_VFORK);
Expand Down

0 comments on commit 252a824

Please sign in to comment.