Help! - DRIVER_IRQL_NOT_LESS_OR_EQUAL on IRQL 0

I’m working on a worker thread in my FS driver; I use
NEITHERIO so I need to create an MDL for the user suplied
buffer when I create the work items (irp contexts)

I tried to check and print the IRQL level and other
parameters, and I get IRQL = 0 (PASSIVE_LEVEL), but
the MmProbeAndLockPages fires bugcheck 0xD1

I include the whole routine, can sombody write me, what
is - or might be - the problem?

NTSTATUS
FsdQueueLoadWorkItem(
PFSD_LOAD_WORK_ITEM WorkItem,
PIRP Irp,
PIO_STACK_LOCATION IrpSp
)
// called in user thread context
{
NTSTATUS Status = STATUS_SUCCESS;
PFSD_FILE_CONTROL_BLOCK Fcb;
KIRQL Irql;

Fcb = WorkItem->Ccb->Fcb;

Irql = KeGetCurrentIrql();

KdPrint((“FsdQueueLoadWorkItem - Irql = %d\n”, Irql));
KdPrint((“Irp->MdlAddress = 0x%08lx\n”, Irp->MdlAddress));
KdPrint((“Irp->UserBuffer = 0x%08lx\n”, Irp->UserBuffer));
KdPrint((“Length = %08ld\n”, IrpSp->Parameters.Read.Length));

__try
{
ProbeForWrite(Irp->UserBuffer, IrpSp->Parameters.Read.Length, 1);
Status = STATUS_SUCCESS;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Status = STATUS_INVALID_USER_BUFFER;
}

if (Status == STATUS_SUCCESS)
{
KdPrint((“Irp->UserBuffer is valid\n”));
}
else
{
KdPrint((“Irp->UserBuffer is INVALID\n”));
return Status;
}

if (Irp->MdlAddress == NULL)
{
WorkItem->Mdl = IoAllocateMdl( Irp->UserBuffer,
IrpSp->Parameters.Read.Length,
FALSE,
FALSE,
Irp );

if (WorkItem->Mdl != NULL)
{
WorkItem->MdlAllocated = TRUE;
Irql = KeGetCurrentIrql();
KdPrint((“MmProbeAndLockPages - Irql = %d\n”, Irql));
// this prints always 0

__try
{
if (Irql >= DISPATCH_LEVEL)
{
Status = STATUS_INVALID_USER_BUFFER;
}
else
{
MmProbeAndLockPages( WorkItem->Mdl, KernelMode, IoWriteAccess );
Status = STATUS_SUCCESS;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Status = GetExceptionCode();
}

if ((WorkItem->MdlAllocated) && (Status != STATUS_SUCCESS))
{
IoFreeMdl( WorkItem->Mdl );
WorkItem->MdlAllocated = FALSE;
WorkItem->Mdl = NULL;
Irp->MdlAddress = NULL;
}
}

if (Status != STATUS_SUCCESS)
{
return Status;
}
}
else
{
WorkItem->MdlAllocated = FALSE;
}

// mark IRP pending
IoMarkIrpPending(WorkItem->Irp);

// queue work item
AcquireLock(Fcb->LoadQueueLock);
InsertTailList(&(Fcb->LoadQueue), &(WorkItem->Next));
ReleaseLock(Fcb->LoadQueueLock);

// wake up processing thread
KeSetEvent(&(Fcb->LoadQueueEvent), 0, FALSE);

// return pending status
Status = STATUS_PENDING;
return Status;
}

the bugcheck’s second parameter is 2, so
it should mean that I try to lock pageable
memory at DISPATCH_LEVEL, but the KeGetCurrentIrql()
returns 0 (PASSIVE_LEVEL)

thanks in advance,
Sandor

ps. the Irp->UserBuffer is valid and writeable,
and the MDL is allocated

ps2. sometimes when I tried to fix this I also
get bugcheck code 0x4E PFN_LIST_CORRUPT; any
relevance or idea? what should that mean?


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Your call to MmProbeAndLockPages should probably be called with “UserMode” instead of “KernelMode.” Even more correct, you should probably use something like IoGetRequestorMode(Irp). (That may not be the exact function name. I don’t have the IFS kit installed at the moment.)

-----Original Message-----
From: xxxxx@kolozsvar.ro [mailto:xxxxx@kolozsvar.ro]
Sent: Friday, February 22, 2002 1:21 AM
To: File Systems Developers
Subject: [ntfsd] Help! - DRIVER_IRQL_NOT_LESS_OR_EQUAL on IRQL 0

I’m working on a worker thread in my FS driver; I use
NEITHERIO so I need to create an MDL for the user suplied
buffer when I create the work items (irp contexts)

I tried to check and print the IRQL level and other
parameters, and I get IRQL = 0 (PASSIVE_LEVEL), but
the MmProbeAndLockPages fires bugcheck 0xD1

I include the whole routine, can sombody write me, what
is - or might be - the problem?

NTSTATUS
FsdQueueLoadWorkItem(
PFSD_LOAD_WORK_ITEM WorkItem,
PIRP Irp,
PIO_STACK_LOCATION IrpSp
)
// called in user thread context
{
NTSTATUS Status = STATUS_SUCCESS;
PFSD_FILE_CONTROL_BLOCK Fcb;
KIRQL Irql;

Fcb = WorkItem->Ccb->Fcb;

Irql = KeGetCurrentIrql();

KdPrint((“FsdQueueLoadWorkItem - Irql = %d\n”, Irql));
KdPrint((“Irp->MdlAddress = 0x%08lx\n”, Irp->MdlAddress));
KdPrint((“Irp->UserBuffer = 0x%08lx\n”, Irp->UserBuffer));
KdPrint((“Length = %08ld\n”, IrpSp->Parameters.Read.Length));

__try
{
ProbeForWrite(Irp->UserBuffer, IrpSp->Parameters.Read.Length, 1);
Status = STATUS_SUCCESS;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Status = STATUS_INVALID_USER_BUFFER;
}

if (Status == STATUS_SUCCESS)
{
KdPrint((“Irp->UserBuffer is valid\n”));
}
else
{
KdPrint((“Irp->UserBuffer is INVALID\n”));
return Status;
}

if (Irp->MdlAddress == NULL)
{
WorkItem->Mdl = IoAllocateMdl( Irp->UserBuffer,
IrpSp->Parameters.Read.Length,
FALSE,
FALSE,
Irp );

if (WorkItem->Mdl != NULL)
{
WorkItem->MdlAllocated = TRUE;
Irql = KeGetCurrentIrql();
KdPrint((“MmProbeAndLockPages - Irql = %d\n”, Irql));
// this prints always 0

__try
{
if (Irql >= DISPATCH_LEVEL)
{
Status = STATUS_INVALID_USER_BUFFER;
}
else
{
MmProbeAndLockPages( WorkItem->Mdl, KernelMode, IoWriteAccess );
Status = STATUS_SUCCESS;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Status = GetExceptionCode();
}

if ((WorkItem->MdlAllocated) && (Status != STATUS_SUCCESS))
{
IoFreeMdl( WorkItem->Mdl );
WorkItem->MdlAllocated = FALSE;
WorkItem->Mdl = NULL;
Irp->MdlAddress = NULL;
}
}

if (Status != STATUS_SUCCESS)
{
return Status;
}
}
else
{
WorkItem->MdlAllocated = FALSE;
}

// mark IRP pending
IoMarkIrpPending(WorkItem->Irp);

// queue work item
AcquireLock(Fcb->LoadQueueLock);
InsertTailList(&(Fcb->LoadQueue), &(WorkItem->Next));
ReleaseLock(Fcb->LoadQueueLock);

// wake up processing thread
KeSetEvent(&(Fcb->LoadQueueEvent), 0, FALSE);

// return pending status
Status = STATUS_PENDING;
return Status;
}

the bugcheck’s second parameter is 2, so
it should mean that I try to lock pageable
memory at DISPATCH_LEVEL, but the KeGetCurrentIrql()
returns 0 (PASSIVE_LEVEL)

thanks in advance,
Sandor

ps. the Irp->UserBuffer is valid and writeable,
and the MDL is allocated

ps2. sometimes when I tried to fix this I also
get bugcheck code 0x4E PFN_LIST_CORRUPT; any
relevance or idea? what should that mean?


You are currently subscribed to ntfsd as: xxxxx@inin.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Your call to MmProbeAndLockPages should probably be called with =

“UserMode” instead of “KernelMode.” Even more correct, you should =
probably use something like IoGetRequestorMode(Irp). (That may not be =
the exact function name. I don’t have the IFS kit installed at the =
moment.)

thanks!
Irp->RequestorMode
was the solution

Sandor