Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_syscall.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | syscallenter(struct thread *td) | ||||
VM_CNT_INC(v_syscall); | VM_CNT_INC(v_syscall); | ||||
p = td->td_proc; | p = td->td_proc; | ||||
sa = &td->td_sa; | sa = &td->td_sa; | ||||
td->td_pticks = 0; | td->td_pticks = 0; | ||||
if (__predict_false(td->td_cowgen != p->p_cowgen)) | if (__predict_false(td->td_cowgen != p->p_cowgen)) | ||||
thread_cow_update(td); | thread_cow_update(td); | ||||
traced = (p->p_flag & P_TRACED) != 0; | traced = (p->p_flag & P_TRACED) != 0; | ||||
if (__predict_false(traced || td->td_dbgflags & TDB_USERWR)) { | // if we're not traced, we won't care about TDB_USERWR; debugger cannot | ||||
// attach and set it before we get to callp->sy_call(). | |||||
if (__predict_false(traced)) { | |||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
td->td_dbgflags &= ~TDB_USERWR; | td->td_dbgflags &= ~TDB_USERWR; | ||||
if (traced) | if (traced) | ||||
td->td_dbgflags |= TDB_SCE; | td->td_dbgflags |= TDB_SCE; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
} | } | ||||
error = (p->p_sysent->sv_fetch_syscall_args)(td); | error = (p->p_sysent->sv_fetch_syscall_args)(td); | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (KTRPOINT(td, KTR_SYSCALL)) | if (KTRPOINT(td, KTR_SYSCALL)) | ||||
ktrsyscall(sa->code, sa->narg, sa->args); | ktrsyscall(sa->code, sa->narg, sa->args); | ||||
#endif | #endif | ||||
KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code), | KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code), | ||||
(uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0], | (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0], | ||||
"arg1:%p", sa->args[1], "arg2:%p", sa->args[2]); | "arg1:%p", sa->args[1], "arg2:%p", sa->args[2]); | ||||
if (__predict_false(error != 0)) { | if (__predict_false(error != 0)) { | ||||
td->td_errno = error; | td->td_errno = error; | ||||
goto retval; | goto retval; | ||||
} | } | ||||
if (__predict_false((p->p_flag & P_TRACED) != 0)) { | if (__predict_false(traced)) { | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (p->p_ptevents & PTRACE_SCE) | if (p->p_ptevents & PTRACE_SCE) | ||||
ptracestop((td), SIGTRAP, NULL); | ptracestop((td), SIGTRAP, NULL); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
} | |||||
if (__predict_false((td->td_dbgflags & TDB_USERWR) != 0)) { | if (__predict_false((td->td_dbgflags & TDB_USERWR) != 0)) { | ||||
/* | /* | ||||
* Reread syscall number and arguments if debugger | * Reread syscall number and arguments if debugger | ||||
* modified registers or memory. | * modified registers or memory. | ||||
*/ | */ | ||||
error = (p->p_sysent->sv_fetch_syscall_args)(td); | error = (p->p_sysent->sv_fetch_syscall_args)(td); | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (KTRPOINT(td, KTR_SYSCALL)) | if (KTRPOINT(td, KTR_SYSCALL)) | ||||
ktrsyscall(sa->code, sa->narg, sa->args); | ktrsyscall(sa->code, sa->narg, sa->args); | ||||
#endif | #endif | ||||
if (error != 0) { | if (error != 0) { | ||||
td->td_errno = error; | td->td_errno = error; | ||||
goto retval; | goto retval; | ||||
} | |||||
} | } | ||||
} | } | ||||
#ifdef CAPABILITY_MODE | #ifdef CAPABILITY_MODE | ||||
/* | /* | ||||
* In capability mode, we only allow access to system calls | * In capability mode, we only allow access to system calls | ||||
* flagged with SYF_CAPENABLED. | * flagged with SYF_CAPENABLED. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |