From 88520fea699fb9f3a6fd804df6688f0c6166c561 Mon Sep 17 00:00:00 2001 From: brucec Date: Sun, 4 Mar 2012 17:08:43 +0000 Subject: Fix race condition in KfRaiseIrql(). After getting the current irql, if the kthread gets preempted and subsequently runs on a different CPU, the saved irql could be wrong. Also, correct the panic string. PR: kern/165630 Submitted by: Vladislav Movchan --- sys/compat/ndis/subr_hal.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/compat/ndis/subr_hal.c b/sys/compat/ndis/subr_hal.c index 45f3440..62d97ad 100644 --- a/sys/compat/ndis/subr_hal.c +++ b/sys/compat/ndis/subr_hal.c @@ -392,16 +392,18 @@ KfRaiseIrql(uint8_t irql) { uint8_t oldirql; + sched_pin(); oldirql = KeGetCurrentIrql(); /* I am so going to hell for this. */ if (oldirql > irql) - panic("IRQL_NOT_LESS_THAN"); + panic("IRQL_NOT_LESS_THAN_OR_EQUAL"); - if (oldirql != DISPATCH_LEVEL) { - sched_pin(); + if (oldirql != DISPATCH_LEVEL) mtx_lock(&disp_lock[curthread->td_oncpu]); - } + else + sched_unpin(); + /*printf("RAISE IRQL: %d %d\n", irql, oldirql);*/ return (oldirql); -- cgit v1.1