summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-01-27 21:37:43 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-01-27 21:37:43 +0000
commit10573611b43e8082c286b3e78d3b4d021883b6e8 (patch)
treecb8f7f71e07371207498a93a212a3c444cfeacf5
parent32cb8b928ab479168c225f3499c467fc1c2c443f (diff)
downloadFreeBSD-src-10573611b43e8082c286b3e78d3b4d021883b6e8.zip
FreeBSD-src-10573611b43e8082c286b3e78d3b4d021883b6e8.tar.gz
filemon_dtr: Lock the associated filemon handle before writing to it.
Reported by: mjg MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
-rw-r--r--sys/dev/filemon/filemon.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c
index 909e0cf..0ec8346 100644
--- a/sys/dev/filemon/filemon.c
+++ b/sys/dev/filemon/filemon.c
@@ -126,14 +126,16 @@ filemon_dtr(void *data)
struct filemon *filemon = data;
if (filemon != NULL) {
- struct file *fp = filemon->fp;
+ struct file *fp;
- /* Get exclusive write access. */
+ /* Follow same locking order as filemon_pid_check. */
filemon_lock_write();
+ filemon_filemon_lock(filemon);
/* Remove from the in-use list. */
TAILQ_REMOVE(&filemons_inuse, filemon, link);
+ fp = filemon->fp;
filemon->fp = NULL;
filemon->pid = -1;
@@ -141,6 +143,7 @@ filemon_dtr(void *data)
TAILQ_INSERT_TAIL(&filemons_free, filemon, link);
/* Give up write access. */
+ filemon_filemon_unlock(filemon);
filemon_unlock_write();
if (fp != NULL)
OpenPOWER on IntegriCloud