-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from marksteward/master
Split out SIGSYS handling and redirect accept to accept4
- Loading branch information
Showing
4 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <errno.h> /* E*, */ | ||
#include <signal.h> /* SIGSYS, */ | ||
|
||
#include "cli/note.h" | ||
#include "syscall/chain.h" | ||
#include "tracee/seccomp.h" | ||
|
||
|
||
int handle_seccomp_event(Tracee* tracee) { | ||
|
||
word_t sysnum; | ||
int signal; | ||
word_t instr_pointer; | ||
|
||
signal = SIGSYS; | ||
|
||
int sigsys_fetch_status = fetch_regs(tracee); | ||
if (sigsys_fetch_status != 0) { | ||
VERBOSE(tracee, 1, "Couldn't fetch regs on seccomp SIGSYS"); | ||
return signal; | ||
} | ||
print_current_regs(tracee, 3, "seccomp SIGSYS"); | ||
tracee->restore_original_regs = false; | ||
|
||
sysnum = get_sysnum(tracee, CURRENT); | ||
|
||
switch (sysnum) { | ||
case PR_accept: | ||
set_sysnum(tracee, PR_accept4); | ||
poke_reg(tracee, SYSARG_4, 0); | ||
|
||
/* Move the instruction pointer back to the original trap */ | ||
instr_pointer = peek_reg(tracee, CURRENT, INSTR_POINTER); | ||
poke_reg(tracee, INSTR_POINTER, instr_pointer - SYSTRAP_SIZE); | ||
/* Break as usual on entry to syscall */ | ||
tracee->restart_how = PTRACE_SYSCALL; | ||
push_specific_regs(tracee, true); | ||
|
||
/* Swallow signal */ | ||
signal = 0; | ||
break; | ||
|
||
case PR_set_robust_list: | ||
default: | ||
/* Set errno to -ENOSYS */ | ||
poke_reg(tracee, SYSARG_RESULT, -ENOSYS); | ||
push_specific_regs(tracee, false); | ||
|
||
/* Swallow signal */ | ||
signal = 0; | ||
break; | ||
} | ||
|
||
/* Reset status so next SIGTRAP | 0x80 is | ||
* recognized as syscall entry */ | ||
tracee->status = 0; | ||
|
||
return signal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "tracee/tracee.h" | ||
|
||
int handle_seccomp_event(Tracee* tracee); |