From 42be6159e300a482c7f3d74d6a18e0a32f650427 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 7 Oct 2015 00:50:26 +0000 Subject: [PATCH] MFC 287870: Always clear TDB_USERWR before fetching system call arguments. The TDB_USERWR flag may still be set after a debugger detaches from a process via PT_DETACH. Previously the flag would never be cleared forcing a double fetch of the system call arguments for each system call. Note that the flag cannot be cleared at PT_DETACH time in case one of the threads in the process is currently stopped in syscallenter() and the debugger has modified the arguments for that pending system call before detaching. git-svn-id: svn://svn.freebsd.org/base/stable/9@288969 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/kern/subr_syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index 5aee68428..2d95a23ba 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -64,14 +64,14 @@ syscallenter(struct thread *td, struct syscall_args *sa) td->td_pticks = 0; if (td->td_ucred != p->p_ucred) cred_update_thread(td); - if (p->p_flag & P_TRACED) { - traced = 1; + traced = (p->p_flag & P_TRACED) != 0; + if (traced || td->td_dbgflags & TDB_USERWR) { PROC_LOCK(p); td->td_dbgflags &= ~TDB_USERWR; - td->td_dbgflags |= TDB_SCE; + if (traced) + td->td_dbgflags |= TDB_SCE; PROC_UNLOCK(p); - } else - traced = 0; + } error = (p->p_sysent->sv_fetch_syscall_args)(td, sa); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSCALL)) -- 2.45.0