]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Always clear TDB_USERWR before fetching system call arguments. The
authorjhb <jhb@FreeBSD.org>
Wed, 16 Sep 2015 20:55:00 +0000 (20:55 +0000)
committerjhb <jhb@FreeBSD.org>
Wed, 16 Sep 2015 20:55:00 +0000 (20:55 +0000)
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.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D3678

sys/kern/subr_syscall.c

index 6d12b611b2dbbf34e6ee7a4592e2f5ea05ef8523..af096138c208fac0b1491d19b5621fd8794aefae 100644 (file)
@@ -63,14 +63,14 @@ syscallenter(struct thread *td, struct syscall_args *sa)
        td->td_pticks = 0;
        if (td->td_cowgen != p->p_cowgen)
                thread_cow_update(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))