From owner-svn-src-head@FreeBSD.ORG Sat Aug 30 03:10:57 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 03529D97; Sat, 30 Aug 2014 03:10:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E24281EF4; Sat, 30 Aug 2014 03:10:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7U3Auue051085; Sat, 30 Aug 2014 03:10:56 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7U3Au8G051081; Sat, 30 Aug 2014 03:10:56 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201408300310.s7U3Au8G051081@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 30 Aug 2014 03:10:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270834 - in head/sys: cddl/contrib/opensolaris/uts/common/dtrace compat/linprocfs kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Aug 2014 03:10:57 -0000 Author: mjg Date: Sat Aug 30 03:10:55 2014 New Revision: 270834 URL: http://svnweb.freebsd.org/changeset/base/270834 Log: Add missing proctree locking to fill_kinfo_proc consumers. This fixes r270444. Pointy hat: mjg Reported by: many MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c head/sys/compat/linprocfs/linprocfs.c head/sys/kern/imgact_elf.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Sat Aug 30 02:13:09 2014 (r270833) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Sat Aug 30 03:10:55 2014 (r270834) @@ -2311,9 +2311,11 @@ fasttrap_ioctl(struct cdev *dev, u_long * Report an error if the process doesn't exist * or is actively being birthed. */ + sx_slock(&proctree_lock); p = pfind(pid); if (p) fill_kinfo_proc(p, &kp); + sx_sunlock(&proctree_lock); if (p == NULL || kp.ki_stat == SIDL) { #if defined(sun) mutex_exit(&pidlock); @@ -2377,9 +2379,11 @@ err: * Report an error if the process doesn't exist * or is actively being birthed. */ + sx_slock(&proctree_lock); p = pfind(pid); if (p) fill_kinfo_proc(p, &kp); + sx_sunlock(&proctree_lock); if (p == NULL || kp.ki_stat == SIDL) { #if defined(sun) mutex_exit(&pidlock); Modified: head/sys/compat/linprocfs/linprocfs.c ============================================================================== --- head/sys/compat/linprocfs/linprocfs.c Sat Aug 30 02:13:09 2014 (r270833) +++ head/sys/compat/linprocfs/linprocfs.c Sat Aug 30 03:10:55 2014 (r270834) @@ -645,8 +645,10 @@ linprocfs_doprocstat(PFS_FILL_ARGS) static int ratelimit = 0; vm_offset_t startcode, startdata; + sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); + sx_sunlock(&proctree_lock); if (p->p_vmspace) { startcode = (vm_offset_t)p->p_vmspace->vm_taddr; startdata = (vm_offset_t)p->p_vmspace->vm_daddr; @@ -722,9 +724,11 @@ linprocfs_doprocstatm(PFS_FILL_ARGS) struct kinfo_proc kp; segsz_t lsize; + sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); PROC_UNLOCK(p); + sx_sunlock(&proctree_lock); /* * See comments in linprocfs_doprocstatus() regarding the @@ -757,6 +761,7 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) struct sigacts *ps; int i; + sx_slock(&proctree_lock); PROC_LOCK(p); td2 = FIRST_THREAD_IN_PROC(p); /* XXXKSE pretend only one thread */ @@ -795,6 +800,8 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) } fill_kinfo_proc(p, &kp); + sx_sunlock(&proctree_lock); + sbuf_printf(sb, "Name:\t%s\n", p->p_comm); /* XXX escape */ sbuf_printf(sb, "State:\t%s\n", state); Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Sat Aug 30 02:13:09 2014 (r270833) +++ head/sys/kern/imgact_elf.c Sat Aug 30 03:10:55 2014 (r270834) @@ -1783,8 +1783,10 @@ __elfN(note_procstat_proc)(void *arg, st KASSERT(*sizep == size, ("invalid size")); structsize = sizeof(elf_kinfo_proc_t); sbuf_bcat(sb, &structsize, sizeof(structsize)); + sx_slock(&proctree_lock); PROC_LOCK(p); kern_proc_out(p, sb, ELF_KERN_PROC_MASK); + sx_sunlock(&proctree_lock); } *sizep = size; }