Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2015 17:19:21 +0000 (UTC)
From:      "Simon J. Gerraty" <sjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r284600 - head/sys/dev/filemon
Message-ID:  <201506191719.t5JHJLhV045455@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sjg
Date: Fri Jun 19 17:19:20 2015
New Revision: 284600
URL: https://svnweb.freebsd.org/changeset/base/284600

Log:
  filemon_pid_check needs to hold proctree_lock
  
  Reviewed by:	kib
  MFC after:	few days

Modified:
  head/sys/dev/filemon/filemon_wrapper.c

Modified: head/sys/dev/filemon/filemon_wrapper.c
==============================================================================
--- head/sys/dev/filemon/filemon_wrapper.c	Fri Jun 19 17:00:36 2015	(r284599)
+++ head/sys/dev/filemon/filemon_wrapper.c	Fri Jun 19 17:19:20 2015	(r284600)
@@ -28,6 +28,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/sx.h>
+
 #include "opt_compat.h"
 
 #if __FreeBSD_version > 800032
@@ -84,13 +86,17 @@ filemon_pid_check(struct proc *p)
 {
 	struct filemon *filemon;
 
-	while (p->p_pptr) {
+	sx_slock(&proctree_lock);
+	while (p != initproc) {
 		TAILQ_FOREACH(filemon, &filemons_inuse, link) {
-			if (p->p_pid == filemon->pid)
+			if (p->p_pid == filemon->pid) {
+				sx_xunlock(&proctree_lock);
 				return (filemon);
+			}
 		}
-		p = p->p_pptr;
+		p = proc_realparent(p);
 	}
+	sx_xunlock(&proctree_lock);
 	return (NULL);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506191719.t5JHJLhV045455>