Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intercept: Abort via the equivalent of raise(SIGABRT) #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -501,6 +502,8 @@ void
xabort_errno(int error_code, const char *msg)
{
static const char main_msg[] = " libsyscall_intercept error\n";
int tid;
pid_t pid;

if (msg != NULL) {
/* not using libc - inline strlen */
Expand All @@ -527,7 +530,11 @@ xabort_errno(int error_code, const char *msg)
}

syscall_no_intercept(SYS_write, 2, main_msg, sizeof(main_msg) - 1);
syscall_no_intercept(SYS_exit_group, 1);

/* abort(), but without using glibc */
tid = syscall_no_intercept(SYS_gettid);
pid = syscall_no_intercept(SYS_getpid);
syscall(SYS_tgkill, pid, tid, SIGABRT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, why is it syscall here, and why not syscall_no_intercept?
Your comment says "without glibc", but syscall is a function in libc, which is going to be intercepted actually...


__builtin_unreachable();
}
Expand Down