From owner-cvs-all@FreeBSD.ORG Wed Feb 22 18:57:51 2006 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E321316A420; Wed, 22 Feb 2006 18:57:51 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B6FB43D6A; Wed, 22 Feb 2006 18:57:50 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1MIvo3J072908; Wed, 22 Feb 2006 18:57:50 GMT (envelope-from jhb@repoman.freebsd.org) Received: (from jhb@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1MIvoMx072907; Wed, 22 Feb 2006 18:57:50 GMT (envelope-from jhb) Message-Id: <200602221857.k1MIvoMx072907@repoman.freebsd.org> From: John Baldwin Date: Wed, 22 Feb 2006 18:57:50 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/sys/alpha/alpha machdep.c trap.c src/sys/arm/arm machdep.c undefined.c src/sys/fs/pseudofs pseudofs_vnops.c src/sys/i386/linux linux_ptrace.c src/sys/ia64/ia64 machdep.c src/sys/kern kern_exit.c kern_kse.c sys_process.c src/sys/sys ... X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2006 18:57:52 -0000 jhb 2006-02-22 18:57:50 UTC FreeBSD src repository Modified files: sys/alpha/alpha machdep.c trap.c sys/arm/arm machdep.c undefined.c sys/fs/pseudofs pseudofs_vnops.c sys/i386/linux linux_ptrace.c sys/ia64/ia64 machdep.c sys/kern kern_exit.c kern_kse.c sys_process.c sys/sys proc.h Log: Close some races between procfs/ptrace and exit(2): - Reorder the events in exit(2) slightly so that we trigger the S_EXIT stop event earlier. After we have signalled that, we set P_WEXIT and then wait for any processes with a hold on the vmspace via PHOLD to release it. PHOLD now KASSERT()'s that P_WEXIT is clear when it is invoked, and PRELE now does a wakeup if P_WEXIT is set and p_lock drops to zero. - Change proc_rwmem() to require that the processing read from has its vmspace held via PHOLD by the caller and get rid of all the junk to screw around with the vmspace reference count as we no longer need it. - In ptrace() and pseudofs(), treat a process with P_WEXIT set as if it doesn't exist. - Only do one PHOLD in kern_ptrace() now, and do it earlier so it covers FIX_SSTEP() (since on alpha at least this can end up calling proc_rwmem() to clear an earlier single-step simualted via a breakpoint). We only do one to avoid races. Also, by making the EINVAL error for unknown requests be part of the default: case in the switch, the various switch cases can now just break out to return which removes a _lot_ of duplicated PRELE and proc unlocks, etc. Also, it fixes at least one bug where a LWP ptrace command could return EINVAL with the proc lock still held. - Changed the locking for ptrace_single_step(), ptrace_set_pc(), and ptrace_clear_single_step() to always be called with the proc lock held (it was a mixed bag previously). Alpha and arm have to drop the lock while the mess around with breakpoints, but other archs avoid extra lock release/acquires in ptrace(). I did have to fix a couple of other consumers in kern_kse and a few other places to hold the proc lock and PHOLD. Tested by: ps (1 mostly, but some bits of 2-4 as well) MFC after: 1 week Revision Changes Path 1.238 +24 -3 src/sys/alpha/alpha/machdep.c 1.129 +4 -0 src/sys/alpha/alpha/trap.c 1.21 +15 -1 src/sys/arm/arm/machdep.c 1.11 +4 -0 src/sys/arm/arm/undefined.c 1.59 +8 -0 src/sys/fs/pseudofs/pseudofs_vnops.c 1.17 +6 -0 src/sys/i386/linux/linux_ptrace.c 1.207 +2 -0 src/sys/ia64/ia64/machdep.c 1.285 +22 -5 src/sys/kern/kern_exit.c 1.223 +16 -2 src/sys/kern/kern_kse.c 1.137 +60 -104 src/sys/kern/sys_process.c 1.454 +3 -0 src/sys/sys/proc.h