summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_intr.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-04-17 18:20:38 +0000
committerjhb <jhb@FreeBSD.org>2006-04-17 18:20:38 +0000
commitd535a5cb818e93fdb882b2748621d7367c013113 (patch)
tree6e1e68443c878ae084bc35e7e36a8edf68ad3352 /sys/kern/kern_intr.c
parentb4b950d049176bd4834f960bca79c4a2bdfd88c4 (diff)
downloadFreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.zip
FreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.tar.gz
Change msleep() and tsleep() to not alter the calling thread's priority
if the specified priority is zero. This avoids a race where the calling thread could read a snapshot of it's current priority, then a different thread could change the first thread's priority, then the original thread would call sched_prio() inside msleep() undoing the change made by the second thread. I used a priority of zero as no thread that calls msleep() or tsleep() should be specifying a priority of zero anyway. The various places that passed 'curthread->td_priority' or some variant as the priority now pass 0.
Diffstat (limited to 'sys/kern/kern_intr.c')
-rw-r--r--sys/kern/kern_intr.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index fae8e97..042a0ec 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -373,8 +373,7 @@ intr_event_add_handler(struct intr_event *ie, const char *name,
/* Create a thread if we need one. */
while (ie->ie_thread == NULL && !(flags & INTR_FAST)) {
if (ie->ie_flags & IE_ADDING_THREAD)
- msleep(ie, &ie->ie_lock, curthread->td_priority,
- "ithread", 0);
+ msleep(ie, &ie->ie_lock, 0, "ithread", 0);
else {
ie->ie_flags |= IE_ADDING_THREAD;
mtx_unlock(&ie->ie_lock);
@@ -460,8 +459,7 @@ ok:
TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
mtx_unlock_spin(&sched_lock);
while (handler->ih_flags & IH_DEAD)
- msleep(handler, &ie->ie_lock, curthread->td_priority, "iev_rmh",
- 0);
+ msleep(handler, &ie->ie_lock, 0, "iev_rmh", 0);
intr_event_update(ie);
#ifdef notyet
/*
@@ -685,7 +683,7 @@ ithread_execute_handlers(struct proc *p, struct intr_event *ie)
ie->ie_name);
ie->ie_warned = 1;
}
- tsleep(&ie->ie_count, curthread->td_priority, "istorm", 1);
+ tsleep(&ie->ie_count, 0, "istorm", 1);
} else
ie->ie_count++;
OpenPOWER on IntegriCloud