NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS IRP is passed down - simple passthru filter

Hello,

AT the moment i’m faced with a bizarre crash that occurs on NT 4.0
with a SCSIPORT filter driver.

To get a better handle on this problem, i’ve stripped away all but
just enough to recreate this problem from development version of
the SCSIPORT filter driver i’m working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i’m able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal
IRP to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI
I/O requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI
requests that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that
involves data read or write, eg. READ, INQUIRY, WRITE where it
will crash the system. Without the filter driver installed these
commands work just fine. Non-data commands such as TEST UNIT READY,
START STOP UNIT, and alike works okay.

I’m sure there’s something wrong with this simple passthru filter
driver, but i don’t see it.

All this passthru filter driver does is pass down the IRP. This
driver has a common dispatch routine for all IRP_MJ_XXX, and that
dispatch routine does nothing more than call the SCSIPORT driver
passing down the IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints
that dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and
even used 3rd party application such as “DeviceFilter v2.2” to
analyze for potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present,
no crash, but soon as filter driver is used to pass down the IRP
from DiskPerfPassThru dispatch to SCSIPORT, i get crash. And
this dispatch absolutely does no processing on IRP it gets. Simple
passthru, that’s all.

If anyone’s interested in more detail, feel free to ask and i
can provide whatever is needed.

So the question is, is there some sort of trick to be used to
pass down IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control
code of 0 with SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample
here, but if anyone’s interested i can share that too), going through
the same passthru mechanism, passing those IRPs down to SCSIPORT
works fine. Only from ASPI32.SYS i get the crash.

This is really bizzare…

I’m currently in conversation with Microsoft DDK support engineer
and we’ve gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the
nature of this crash. I’ve sent him a crash dump so hopefully
that would shed some insight into this problem.

I’ve included below few dumps from windbg if anyone’s interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37
fbf24ea0 8016a194 nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.

*********************************************************************
* Symbols can not be loaded because symbol path is not initialized. *
* *
* The Symbol Path can be set by: *
* using the _NT_SYMBOL_PATH environment variable. *
* using the -y <symbol_path> argument when starting the debugger. *
* using .sympath and .sympath+ *
**************************************************************
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -


*
Bugcheck Analysis *
*


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS -
Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v


*
Bugcheck Analysis *
*


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address
at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include “ntddk.h”
#include “stdarg.h”
#include “stdio.h”
#include “ntdddisk.h”
#include “ntddscsi.h”
#include “srb.h”
#include “scsi.h”

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,

);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there’s a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, “\Device\ScsiPort2”);
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver, i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,

)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG</symbol_path>

Wow.

Does it make any difference if you don’t increment the current location
and CurrentStackLocation? That seems like it should be benign but
perhaps it’s not.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Wednesday, May 12, 2004 9:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS
IRP is passed down - simple passthru filter driver included

Hello,

AT the moment i’m faced with a bizarre crash that occurs on NT 4.0 with
a SCSIPORT filter driver.

To get a better handle on this problem, i’ve stripped away all but just
enough to recreate this problem from development version of the SCSIPORT
filter driver i’m working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i’m able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal IRP
to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI I/O
requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI requests
that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that involves
data read or write, eg. READ, INQUIRY, WRITE where it will crash the
system. Without the filter driver installed these commands work just
fine. Non-data commands such as TEST UNIT READY, START STOP UNIT, and
alike works okay.

I’m sure there’s something wrong with this simple passthru filter
driver, but i don’t see it.

All this passthru filter driver does is pass down the IRP. This driver
has a common dispatch routine for all IRP_MJ_XXX, and that dispatch
routine does nothing more than call the SCSIPORT driver passing down the
IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints that
dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and even
used 3rd party application such as “DeviceFilter v2.2” to analyze for
potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present, no crash,
but soon as filter driver is used to pass down the IRP from
DiskPerfPassThru dispatch to SCSIPORT, i get crash. And this dispatch
absolutely does no processing on IRP it gets. Simple passthru, that’s
all.

If anyone’s interested in more detail, feel free to ask and i can
provide whatever is needed.

So the question is, is there some sort of trick to be used to pass down
IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control code of 0 with
SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample here,
but if anyone’s interested i can share that too), going through the same
passthru mechanism, passing those IRPs down to SCSIPORT works fine.
Only from ASPI32.SYS i get the crash.

This is really bizzare…

I’m currently in conversation with Microsoft DDK support engineer and
we’ve gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the nature of
this crash. I’ve sent him a crash dump so hopefully that would shed
some insight into this problem.

I’ve included below few dumps from windbg if anyone’s interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37 fbf24ea0 8016a194
nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.

*********************************************************************
* Symbols can not be loaded because symbol path is not initialized. *
* *
* The Symbol Path can be set by: *
* using the _NT_SYMBOL_PATH environment variable. *
* using the -y <symbol_path> argument when starting the debugger. *
* using .sympath and .sympath+ *
******************************************************************
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

**Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS - Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include “ntddk.h”
#include “stdarg.h”
#include “stdio.h”
#include “ntdddisk.h”
#include “ntddscsi.h”
#include “srb.h”
#include “scsi.h”

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,

);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object
named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there’s a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, “\Device\ScsiPort2”);
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;

NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver,
i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,

)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</symbol_path>

Hello,

Does it make any difference if you don't increment the current
location and CurrentStackLocation?

So i got fed up with using free build of NT4.0 SP6a so last night
i loaded up the checked build (high-encryption) of the OS hoping to
do little bit more serious debugging.

If i skip both,

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

i don't get crash but the ASPI SCSI request fails, probably for
obvious reason.

If i skip only,

Irp->Tail.Overlay.CurrentStackLocation++;

then crash with

Access violation - code c0000005 (!!! second chance !!!)
nt!IopCompleteRequest+0x30e:
8012055f 8908

which is probably expected.

If i skip only the following line instead,

Irp->CurrentLocation++;

then the following IoCallDriver call leads to following page fault,
which is the same page fault i get if i don't skip the 2 stack increment
statements prior to calling IoCallDriver.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

You are right. The fact that i'm using free build gave me incorrect
guestimation of the place where i may have blown up. As you can see
from page fault dump information below the crash occurred at,

SCSIPORT!ScsiPortStartIo+0x101

Now that any insight wisdom you can offer???

I'm running out of ideas...

Regards,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

MM:***PAGE FAULT AT IRQL > 1 Va 18, IRQL 2

*** Fatal System Error: 0x0000000A
(0x00000018,0x00000002,0x00000000,0x80269B3C)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

Connected to Windows NT 4 1381 x86 compatible target, ptr64 FALSE
Loading Kernel Symbols
.....................................
Loading unloaded module list
No unloaded module list present
Loading User Symbols
.................
*******************************************************************************

* *
* Bugcheck Analysis *
* *
*******************************************************************************

Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 80269b3c}

*** ERROR: Module load completed but symbols could not be loaded for
Aspi32.SYS
*** WARNING: Unable to verify checksum for WNASPI32.DLL
*** ERROR: Symbol file could not be found. Defaulted to export symbols
for WNASPI32.DLL -
Probably caused by : passthru.sys ( passthru!DiskPerfPassThru+3b )

Followup: MachineOwner

nt!RtlpBreakWithStatusInstruction:
80165c58 cc int 3
kd> !analyze -v
*******************************************************************************

* *
* Bugcheck Analysis *
* *
*******************************************************************************

IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address
at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 80269b3c, address which referenced memory

Debugging Details:

READ_ADDRESS: 00000018

CURRENT_IRQL: 2

FAULTING_IP:
SCSIPORT!ScsiPortStartIo+101
80269b3c 8b4818 mov ecx,[eax+0x18]

DEFAULT_BUCKET_ID: DRIVER_FAULT

BUGCHECK_STR: 0xA

TRAP_FRAME: fcb29c30 -- (.trap fffffffffcb29c30)
ErrCode = 00000000
eax=00000000 ebx=80911000 ecx=80913000 edx=00000000 esi=809160e0
edi=80823785
eip=80269b3c esp=fcb29ca4 ebp=fcb29cb8 iopl=0 nv up ei ng nz na po
nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010286
SCSIPORT!ScsiPortStartIo+0x101:
80269b3c 8b4818 mov ecx,[eax+0x18]
Resetting default scope

LAST_CONTROL_TRANSFER: from 8011dd90 to 80269b3c

STACK_TEXT:
fcb29cb8 8011dd90 80916028 807d9008 80919a08
SCSIPORT!ScsiPortStartIo+0x101
fcb29cd8 802698d4 80916028 807d9008 00000000 nt!IoStartPacket+0x98
fcb29d08 8011c9a9 80916028 807d9008 8090c020
SCSIPORT!ScsiPortDispatch+0x363
fcb29d2c 800863db 00000008 8090c0d8 fcb29d60 nt!IofCallDriver+0x68
fcb29d3c 8011c9a9 8090c020 807d9008 808237bf
passthru!DiskPerfPassThru+0x3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
fcb29d60 f73ba252 807e4148 8084e598 8084e528 nt!IofCallDriver+0x68
WARNING: Stack unwind information not available. Following frames may be
wrong.
fcb29d98 f73b95ce 80826e08 807e4148 8084e528 Aspi32+0x2252
fcb29dc8 8011c9a9 80826d50 8084e528 807ab22c Aspi32+0x15ce
fcb29dec 801c18df 00133040 00133108 801ba801 nt!IofCallDriver+0x68
fcb29e08 801c222f 80826d50 8084e528 807abb68
nt!IopSynchronousServiceTail+0x9f
fcb29e94 801ba8e0 0000002c 00000020 00000000 nt!IopXxxControlFile+0x6f3
fcb29ec8 8017917a 0000002c 00000020 00000000 nt!NtDeviceIoControlFile+0x28

fcb29ec8 6720adfb 0000002c 00000020 00000000 nt!KiSystemService+0x10a
00f3fb7c 77f06695 0000002c 00000020 00000000
ntdll!ZwDeviceIoControlFile+0xb
00f3fbdc 00f424c9 0000002c 9090e080 00133040 KERNEL32!DeviceIoControl+0xb0

00133040 000000c8 00000001 00000100 0001a5e0 WNASPI32!WOWDispatch+0xe99

FOLLOWUP_IP:
passthru!DiskPerfPassThru+3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
800863db 8945f8 mov [ebp-0x8],eax

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: passthru!DiskPerfPassThru+3b

MODULE_NAME: passthru

IMAGE_NAME: passthru.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 40a33502

STACK_COMMAND: .trap fffffffffcb29c30 ; kb

BUCKET_ID: 0xA_passthru!DiskPerfPassThru+3b

Followup: MachineOwner

012345678901234567890123456789012345678901234567890123456789012345678

"Peter Wieland"
Sent by: xxxxx@lists.osr.com
05/13/2004 10:04 AM
Please respond to "Windows System Software Devs Interest List"

To: "Windows System Software Devs Interest List"
cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

Wow.

Does it make any difference if you don't increment the current location
and CurrentStackLocation? That seems like it should be benign but
perhaps it's not.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Wednesday, May 12, 2004 9:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS
IRP is passed down - simple passthru filter driver included

Hello,

AT the moment i'm faced with a bizarre crash that occurs on NT 4.0 with
a SCSIPORT filter driver.

To get a better handle on this problem, i've stripped away all but just
enough to recreate this problem from development version of the SCSIPORT
filter driver i'm working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i'm able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal IRP
to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI I/O
requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI requests
that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that involves
data read or write, eg. READ, INQUIRY, WRITE where it will crash the
system. Without the filter driver installed these commands work just
fine. Non-data commands such as TEST UNIT READY, START STOP UNIT, and
alike works okay.

I'm sure there's something wrong with this simple passthru filter
driver, but i don't see it.

All this passthru filter driver does is pass down the IRP. This driver
has a common dispatch routine for all IRP_MJ_XXX, and that dispatch
routine does nothing more than call the SCSIPORT driver passing down the
IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints that
dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and even
used 3rd party application such as "DeviceFilter v2.2" to analyze for
potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present, no crash,
but soon as filter driver is used to pass down the IRP from
DiskPerfPassThru dispatch to SCSIPORT, i get crash. And this dispatch
absolutely does no processing on IRP it gets. Simple passthru, that's
all.

If anyone's interested in more detail, feel free to ask and i can
provide whatever is needed.

So the question is, is there some sort of trick to be used to pass down
IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control code of 0 with
SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample here,
but if anyone's interested i can share that too), going through the same
passthru mechanism, passing those IRPs down to SCSIPORT works fine.
Only from ASPI32.SYS i get the crash.

This is really bizzare...

I'm currently in conversation with Microsoft DDK support engineer and
we've gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the nature of
this crash. I've sent him a crash dump so hopefully that would shed
some insight into this problem.

I've included below few dumps from windbg if anyone's interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37 fbf24ea0 8016a194
nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.


Symbols can not be loaded because symbol path is not initialized. *
*
The Symbol Path can be set by: *
using the _NT_SYMBOL_PATH environment variable. *
using the -y <symbol_path> argument when starting the debugger. *
using .sympath and .sympath+ *
******
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -
*********************************************************************


*
Bugcheck Analysis *
*
********************************************************************


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS - Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v



*
Bugcheck Analysis *
*
*
*******

IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "ntddk.h"
#include "stdarg.h"
#include "stdio.h"
#include "ntdddisk.h"
#include "ntddscsi.h"
#include "srb.h"
#include "scsi.h"

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,
...
);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object
named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there's a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, "\Device\ScsiPort2");
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;

NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver,
i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,
...
)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG

---
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

---
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</symbol_path>

If you don't skip the stack location then you need to copy all the
parameters to the next stack location. In NT5 you could call
IoCopyCurrentIrpStackLocation - a macro defined as:

#define IoCopyCurrentIrpStackLocationToNext( Irp ) { \
PIO_STACK_LOCATION __irpSp; \
PIO_STACK_LOCATION __nextIrpSp; \
__irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \
__nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \
RtlCopyMemory( __nextIrpSp, __irpSp, FIELD_OFFSET(IO_STACK_LOCATION,
CompletionRoutine)); \
__nextIrpSp->Control = 0; }

This will setup the next stack location for you. Then call the lower
driver.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Thursday, May 13, 2004 11:01 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when
ASPI32.SYS IRP is passed down - simple passthru filter driver included

Hello,

Does it make any difference if you don't increment the current
location and CurrentStackLocation?

So i got fed up with using free build of NT4.0 SP6a so last night i
loaded up the checked build (high-encryption) of the OS hoping to do
little bit more serious debugging.

If i skip both,

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

i don't get crash but the ASPI SCSI request fails, probably for obvious
reason.

If i skip only,

Irp->Tail.Overlay.CurrentStackLocation++;

then crash with

Access violation - code c0000005 (!!! second chance !!!)
nt!IopCompleteRequest+0x30e:
8012055f 8908

which is probably expected.

If i skip only the following line instead,

Irp->CurrentLocation++;

then the following IoCallDriver call leads to following page fault,
which is the same page fault i get if i don't skip the 2 stack increment
statements prior to calling IoCallDriver.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find

it hard to believe that it could be the actual cause of the problem.

You are right. The fact that i'm using free build gave me incorrect
guestimation of the place where i may have blown up. As you can see
from page fault dump information below the crash occurred at,

SCSIPORT!ScsiPortStartIo+0x101

Now that any insight wisdom you can offer???

I'm running out of ideas...

Regards,

-gshin

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+

MM:***PAGE FAULT AT IRQL > 1 Va 18, IRQL 2

*** Fatal System Error: 0x0000000A
(0x00000018,0x00000002,0x00000000,0x80269B3C)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

Connected to Windows NT 4 1381 x86 compatible target, ptr64 FALSE
Loading Kernel Symbols .....................................
Loading unloaded module list
No unloaded module list present
Loading User Symbols
.................
************************************************************************
*******

* *
* Bugcheck Analysis *
* *
************************************************************************
*******

Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 80269b3c}

*** ERROR: Module load completed but symbols could not be loaded for
Aspi32.SYS
*** WARNING: Unable to verify checksum for WNASPI32.DLL
*** ERROR: Symbol file could not be found. Defaulted to export symbols
for WNASPI32.DLL - Probably caused by : passthru.sys (
passthru!DiskPerfPassThru+3b )

Followup: MachineOwner

nt!RtlpBreakWithStatusInstruction:
80165c58 cc int 3
kd> !analyze -v
************************************************************************
*******

* *
* Bugcheck Analysis *
* *
************************************************************************
*******

IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 80269b3c, address which referenced memory

Debugging Details:

READ_ADDRESS: 00000018

CURRENT_IRQL: 2

FAULTING_IP:
SCSIPORT!ScsiPortStartIo+101
80269b3c 8b4818 mov ecx,[eax+0x18]

DEFAULT_BUCKET_ID: DRIVER_FAULT

BUGCHECK_STR: 0xA

TRAP_FRAME: fcb29c30 -- (.trap fffffffffcb29c30)
ErrCode = 00000000
eax=00000000 ebx=80911000 ecx=80913000 edx=00000000 esi=809160e0
edi=80823785
eip=80269b3c esp=fcb29ca4 ebp=fcb29cb8 iopl=0 nv up ei ng nz na
po
nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010286
SCSIPORT!ScsiPortStartIo+0x101:
80269b3c 8b4818 mov ecx,[eax+0x18]
Resetting default scope

LAST_CONTROL_TRANSFER: from 8011dd90 to 80269b3c

STACK_TEXT:
fcb29cb8 8011dd90 80916028 807d9008 80919a08
SCSIPORT!ScsiPortStartIo+0x101
fcb29cd8 802698d4 80916028 807d9008 00000000 nt!IoStartPacket+0x98
fcb29d08 8011c9a9 80916028 807d9008 8090c020
SCSIPORT!ScsiPortDispatch+0x363
fcb29d2c 800863db 00000008 8090c0d8 fcb29d60 nt!IofCallDriver+0x68
fcb29d3c 8011c9a9 8090c020 807d9008 808237bf
passthru!DiskPerfPassThru+0x3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
fcb29d60 f73ba252 807e4148 8084e598 8084e528 nt!IofCallDriver+0x68
WARNING: Stack unwind information not available. Following frames may be

wrong.
fcb29d98 f73b95ce 80826e08 807e4148 8084e528 Aspi32+0x2252
fcb29dc8 8011c9a9 80826d50 8084e528 807ab22c Aspi32+0x15ce
fcb29dec 801c18df 00133040 00133108 801ba801 nt!IofCallDriver+0x68
fcb29e08 801c222f 80826d50 8084e528 807abb68
nt!IopSynchronousServiceTail+0x9f
fcb29e94 801ba8e0 0000002c 00000020 00000000 nt!IopXxxControlFile+0x6f3
fcb29ec8 8017917a 0000002c 00000020 00000000
nt!NtDeviceIoControlFile+0x28

fcb29ec8 6720adfb 0000002c 00000020 00000000 nt!KiSystemService+0x10a
00f3fb7c 77f06695 0000002c 00000020 00000000
ntdll!ZwDeviceIoControlFile+0xb
00f3fbdc 00f424c9 0000002c 9090e080 00133040
KERNEL32!DeviceIoControl+0xb0

00133040 000000c8 00000001 00000100 0001a5e0 WNASPI32!WOWDispatch+0xe99

FOLLOWUP_IP:
passthru!DiskPerfPassThru+3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
800863db 8945f8 mov [ebp-0x8],eax

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: passthru!DiskPerfPassThru+3b

MODULE_NAME: passthru

IMAGE_NAME: passthru.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 40a33502

STACK_COMMAND: .trap fffffffffcb29c30 ; kb

BUCKET_ID: 0xA_passthru!DiskPerfPassThru+3b

Followup: MachineOwner

012345678901234567890123456789012345678901234567890123456789012345678

"Peter Wieland"
Sent by: xxxxx@lists.osr.com
05/13/2004 10:04 AM
Please respond to "Windows System Software Devs Interest List"

To: "Windows System Software Devs Interest List"

cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash
only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

Wow.

Does it make any difference if you don't increment the current location
and CurrentStackLocation? That seems like it should be benign but
perhaps it's not.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Wednesday, May 12, 2004 9:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS
IRP is passed down - simple passthru filter driver included

Hello,

AT the moment i'm faced with a bizarre crash that occurs on NT 4.0 with
a SCSIPORT filter driver.

To get a better handle on this problem, i've stripped away all but just
enough to recreate this problem from development version of the SCSIPORT
filter driver i'm working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i'm able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal IRP
to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI I/O
requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI requests
that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that involves
data read or write, eg. READ, INQUIRY, WRITE where it will crash the
system. Without the filter driver installed these commands work just
fine. Non-data commands such as TEST UNIT READY, START STOP UNIT, and
alike works okay.

I'm sure there's something wrong with this simple passthru filter
driver, but i don't see it.

All this passthru filter driver does is pass down the IRP. This driver
has a common dispatch routine for all IRP_MJ_XXX, and that dispatch
routine does nothing more than call the SCSIPORT driver passing down the
IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints that
dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and even
used 3rd party application such as "DeviceFilter v2.2" to analyze for
potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present, no crash,
but soon as filter driver is used to pass down the IRP from
DiskPerfPassThru dispatch to SCSIPORT, i get crash. And this dispatch
absolutely does no processing on IRP it gets. Simple passthru, that's
all.

If anyone's interested in more detail, feel free to ask and i can
provide whatever is needed.

So the question is, is there some sort of trick to be used to pass down
IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control code of 0 with
SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample here,
but if anyone's interested i can share that too), going through the same
passthru mechanism, passing those IRPs down to SCSIPORT works fine.
Only from ASPI32.SYS i get the crash.

This is really bizzare...

I'm currently in conversation with Microsoft DDK support engineer and
we've gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the nature of
this crash. I've sent him a crash dump so hopefully that would shed
some insight into this problem.

I've included below few dumps from windbg if anyone's interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37 fbf24ea0 8016a194
nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.


Symbols can not be loaded because symbol path is not initialized. *
*
The Symbol Path can be set by: *
using the _NT_SYMBOL_PATH environment variable. *
using the -y <symbol_path> argument when starting the debugger. *
using .sympath and .sympath+ *
******
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -
*********************************************************************


*
Bugcheck Analysis *
*
********************************************************************


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS - Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v



*
Bugcheck Analysis *
*
*
*******

IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "ntddk.h"
#include "stdarg.h"
#include "stdio.h"
#include "ntdddisk.h"
#include "ntddscsi.h"
#include "srb.h"
#include "scsi.h"

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,
...
);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object
named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there's a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, "\Device\ScsiPort2");
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;

NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver,
i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,
...
)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG

---
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

---
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

---
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</symbol_path>

Hello,

If you don’t skip the stack location then you need to copy all the
parameters to the next stack location.

You are correct. I was just trying those experiments as a “what-if”
scenarios.

Since this simple pass-thru filter driver’s dispatch has no
completion routine, i didn’t copy the current stack to next stack
location, but a simple stack skip. But it’s a worth the test. I’ll
give that a try and see what happens.

IoCopyCurrentIrpStackLocationToNext

Nice, handy macro. The NT4 DDK is also missing the macro
IoSkipCurrentIrpStackLocation.

Regards,

-gshin

012345678901234567890123456789012345678901234567890123456789012345678

“Peter Wieland”
Sent by: xxxxx@lists.osr.com
05/13/2004 12:10 PM
Please respond to “Windows System Software Devs Interest List”

To: “Windows System Software Devs Interest List”
cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

If you don’t skip the stack location then you need to copy all the
parameters to the next stack location. In NT5 you could call
IoCopyCurrentIrpStackLocation - a macro defined as:

#define IoCopyCurrentIrpStackLocationToNext( Irp ) { <br> PIO_STACK_LOCATION irpSp; <br> PIO_STACK_LOCATION nextIrpSp; <br> __irpSp = IoGetCurrentIrpStackLocation( (Irp) ); <br>__nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); <br> RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION,
CompletionRoutine)); <br> __nextIrpSp->Control = 0; }

This will setup the next stack location for you. Then call the lower
driver.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Thursday, May 13, 2004 11:01 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when
ASPI32.SYS IRP is passed down - simple passthru filter driver included

Hello,

> Does it make any difference if you don’t increment the current
> location and CurrentStackLocation?
>
So i got fed up with using free build of NT4.0 SP6a so last night i
loaded up the checked build (high-encryption) of the OS hoping to do
little bit more serious debugging.

If i skip both,

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

i don’t get crash but the ASPI SCSI request fails, probably for obvious
reason.

If i skip only,

Irp->Tail.Overlay.CurrentStackLocation++;

then crash with

Access violation - code c0000005 (!!! second chance !!!)
nt!IopCompleteRequest+0x30e:
8012055f 8908

which is probably expected.

If i skip only the following line instead,

Irp->CurrentLocation++;

then the following IoCallDriver call leads to following page fault,
which is the same page fault i get if i don’t skip the 2 stack increment
statements prior to calling IoCallDriver.

> ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find

> it hard to believe that it could be the actual cause of the problem.
>
You are right. The fact that i’m using free build gave me incorrect
guestimation of the place where i may have blown up. As you can see
from page fault dump information below the crash occurred at,

SCSIPORT!ScsiPortStartIo+0x101

Now that any insight wisdom you can offer???

I’m running out of ideas…

Regards,

-gshin

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+

MM: PAGE FAULT AT IRQL > 1 Va 18, IRQL 2

Fatal System Error: 0x0000000A
(0x00000018,0x00000002,0x00000000,0x80269B3C)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

Connected to Windows NT 4 1381 x86 compatible target, ptr64 FALSE
Loading Kernel Symbols …
Loading unloaded module list
No unloaded module list present
Loading User Symbols




*
Bugcheck Analysis *
*



Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 80269b3c}

ERROR: Module load completed but symbols could not be loaded for
Aspi32.SYS
WARNING: Unable to verify checksum for WNASPI32.DLL
ERROR: Symbol file could not be found. Defaulted to export symbols
for WNASPI32.DLL - Probably caused by : passthru.sys (
passthru!DiskPerfPassThru+3b )

Followup: MachineOwner
---------

nt!RtlpBreakWithStatusInstruction:
80165c58 cc int 3
kd> !analyze -v



*
Bugcheck Analysis *
*
**********


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 80269b3c, address which referenced memory

Debugging Details:
------------------

READ_ADDRESS: 00000018

CURRENT_IRQL: 2

FAULTING_IP:
SCSIPORT!ScsiPortStartIo+101
80269b3c 8b4818 mov ecx,[eax+0x18]

DEFAULT_BUCKET_ID: DRIVER_FAULT

BUGCHECK_STR: 0xA

TRAP_FRAME: fcb29c30 – (.trap fffffffffcb29c30)
ErrCode = 00000000
eax=00000000 ebx=80911000 ecx=80913000 edx=00000000 esi=809160e0
edi=80823785
eip=80269b3c esp=fcb29ca4 ebp=fcb29cb8 iopl=0 nv up ei ng nz na
po
nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010286
SCSIPORT!ScsiPortStartIo+0x101:
80269b3c 8b4818 mov ecx,[eax+0x18]
Resetting default scope

LAST_CONTROL_TRANSFER: from 8011dd90 to 80269b3c

STACK_TEXT:
fcb29cb8 8011dd90 80916028 807d9008 80919a08
SCSIPORT!ScsiPortStartIo+0x101
fcb29cd8 802698d4 80916028 807d9008 00000000 nt!IoStartPacket+0x98
fcb29d08 8011c9a9 80916028 807d9008 8090c020
SCSIPORT!ScsiPortDispatch+0x363
fcb29d2c 800863db 00000008 8090c0d8 fcb29d60 nt!IofCallDriver+0x68
fcb29d3c 8011c9a9 8090c020 807d9008 808237bf
passthru!DiskPerfPassThru+0x3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
fcb29d60 f73ba252 807e4148 8084e598 8084e528 nt!IofCallDriver+0x68
WARNING: Stack unwind information not available. Following frames may be

wrong.
fcb29d98 f73b95ce 80826e08 807e4148 8084e528 Aspi32+0x2252
fcb29dc8 8011c9a9 80826d50 8084e528 807ab22c Aspi32+0x15ce
fcb29dec 801c18df 00133040 00133108 801ba801 nt!IofCallDriver+0x68
fcb29e08 801c222f 80826d50 8084e528 807abb68
nt!IopSynchronousServiceTail+0x9f
fcb29e94 801ba8e0 0000002c 00000020 00000000 nt!IopXxxControlFile+0x6f3
fcb29ec8 8017917a 0000002c 00000020 00000000
nt!NtDeviceIoControlFile+0x28

fcb29ec8 6720adfb 0000002c 00000020 00000000 nt!KiSystemService+0x10a
00f3fb7c 77f06695 0000002c 00000020 00000000
ntdll!ZwDeviceIoControlFile+0xb
00f3fbdc 00f424c9 0000002c 9090e080 00133040
KERNEL32!DeviceIoControl+0xb0

00133040 000000c8 00000001 00000100 0001a5e0 WNASPI32!WOWDispatch+0xe99

FOLLOWUP_IP:
passthru!DiskPerfPassThru+3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
800863db 8945f8 mov [ebp-0x8],eax

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: passthru!DiskPerfPassThru+3b

MODULE_NAME: passthru

IMAGE_NAME: passthru.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 40a33502

STACK_COMMAND: .trap fffffffffcb29c30 ; kb

BUCKET_ID: 0xA_passthru!DiskPerfPassThru+3b

Followup: MachineOwner
---------

012345678901234567890123456789012345678901234567890123456789012345678

“Peter Wieland”
Sent by: xxxxx@lists.osr.com
05/13/2004 10:04 AM
Please respond to “Windows System Software Devs Interest List”

To: “Windows System Software Devs Interest List”

cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash
only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

Wow.

Does it make any difference if you don’t increment the current location
and CurrentStackLocation? That seems like it should be benign but
perhaps it’s not.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Wednesday, May 12, 2004 9:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS
IRP is passed down - simple passthru filter driver included

Hello,

AT the moment i’m faced with a bizarre crash that occurs on NT 4.0 with
a SCSIPORT filter driver.

To get a better handle on this problem, i’ve stripped away all but just
enough to recreate this problem from development version of the SCSIPORT
filter driver i’m working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i’m able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal IRP
to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI I/O
requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI requests
that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that involves
data read or write, eg. READ, INQUIRY, WRITE where it will crash the
system. Without the filter driver installed these commands work just
fine. Non-data commands such as TEST UNIT READY, START STOP UNIT, and
alike works okay.

I’m sure there’s something wrong with this simple passthru filter
driver, but i don’t see it.

All this passthru filter driver does is pass down the IRP. This driver
has a common dispatch routine for all IRP_MJ_XXX, and that dispatch
routine does nothing more than call the SCSIPORT driver passing down the
IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints that
dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and even
used 3rd party application such as “DeviceFilter v2.2” to analyze for
potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present, no crash,
but soon as filter driver is used to pass down the IRP from
DiskPerfPassThru dispatch to SCSIPORT, i get crash. And this dispatch
absolutely does no processing on IRP it gets. Simple passthru, that’s
all.

If anyone’s interested in more detail, feel free to ask and i can
provide whatever is needed.

So the question is, is there some sort of trick to be used to pass down
IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control code of 0 with
SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample here,
but if anyone’s interested i can share that too), going through the same
passthru mechanism, passing those IRPs down to SCSIPORT works fine.
Only from ASPI32.SYS i get the crash.

This is really bizzare…

I’m currently in conversation with Microsoft DDK support engineer and
we’ve gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the nature of
this crash. I’ve sent him a crash dump so hopefully that would shed
some insight into this problem.

I’ve included below few dumps from windbg if anyone’s interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37 fbf24ea0 8016a194
nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.

********************************************************
Symbols can not be loaded because symbol path is not initialized. *
*
The Symbol Path can be set by: *
using the _NT_SYMBOL_PATH environment variable. *
using the -y <symbol_path> argument when starting the debugger. *
using .sympath and .sympath+ *
******************************************************************
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

**Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS - Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include “ntddk.h”
#include “stdarg.h”
#include “stdio.h”
#include “ntdddisk.h”
#include “ntddscsi.h”
#include “srb.h”
#include “scsi.h”

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,

);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object
named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there’s a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, “\Device\ScsiPort2”);
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;

NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver,
i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,

)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</symbol_path>

> But it’s a worth the test. I’ll

give that a try and see what happens.

Nope. Same page fault crash. :frowning:

There’s something bad in IRP, but all i’m doing is passing down
the IRP i receive down to SCSIPORT. I just don’t know anymore… :frowning:

-gshin

012345678901234567890123456789012345678901234567890123456789012345678

xxxxx@deadlinemavens.com
Sent by: xxxxx@lists.osr.com
05/13/2004 12:29 PM
Please respond to “Windows System Software Devs Interest List”

To: “Windows System Software Devs Interest List”
cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

Hello,

> If you don’t skip the stack location then you need to copy all the
> parameters to the next stack location.
>
You are correct. I was just trying those experiments as a “what-if”
scenarios.

Since this simple pass-thru filter driver’s dispatch has no
completion routine, i didn’t copy the current stack to next stack
location, but a simple stack skip. But it’s a worth the test. I’ll
give that a try and see what happens.

> IoCopyCurrentIrpStackLocationToNext
>
Nice, handy macro. The NT4 DDK is also missing the macro
IoSkipCurrentIrpStackLocation.

Regards,

-gshin

012345678901234567890123456789012345678901234567890123456789012345678

“Peter Wieland”
Sent by: xxxxx@lists.osr.com
05/13/2004 12:10 PM
Please respond to “Windows System Software Devs Interest List”

To: “Windows System Software Devs Interest List”

cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash
only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

If you don’t skip the stack location then you need to copy all the
parameters to the next stack location. In NT5 you could call
IoCopyCurrentIrpStackLocation - a macro defined as:

#define IoCopyCurrentIrpStackLocationToNext( Irp ) { <br> PIO_STACK_LOCATION irpSp; <br> PIO_STACK_LOCATION nextIrpSp; <br> __irpSp = IoGetCurrentIrpStackLocation( (Irp) ); <br>__nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); <br> RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION,
CompletionRoutine)); <br> __nextIrpSp->Control = 0; }

This will setup the next stack location for you. Then call the lower
driver.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Thursday, May 13, 2004 11:01 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash only when
ASPI32.SYS IRP is passed down - simple passthru filter driver included

Hello,

> Does it make any difference if you don’t increment the current
> location and CurrentStackLocation?
>
So i got fed up with using free build of NT4.0 SP6a so last night i
loaded up the checked build (high-encryption) of the OS hoping to do
little bit more serious debugging.

If i skip both,

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

i don’t get crash but the ASPI SCSI request fails, probably for obvious
reason.

If i skip only,

Irp->Tail.Overlay.CurrentStackLocation++;

then crash with

Access violation - code c0000005 (!!! second chance !!!)
nt!IopCompleteRequest+0x30e:
8012055f 8908

which is probably expected.

If i skip only the following line instead,

Irp->CurrentLocation++;

then the following IoCallDriver call leads to following page fault,
which is the same page fault i get if i don’t skip the 2 stack increment
statements prior to calling IoCallDriver.

> ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find

> it hard to believe that it could be the actual cause of the problem.
>
You are right. The fact that i’m using free build gave me incorrect
guestimation of the place where i may have blown up. As you can see
from page fault dump information below the crash occurred at,

SCSIPORT!ScsiPortStartIo+0x101

Now that any insight wisdom you can offer???

I’m running out of ideas…

Regards,

-gshin

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+

MM: PAGE FAULT AT IRQL > 1 Va 18, IRQL 2

Fatal System Error: 0x0000000A
(0x00000018,0x00000002,0x00000000,0x80269B3C)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

Connected to Windows NT 4 1381 x86 compatible target, ptr64 FALSE
Loading Kernel Symbols …
Loading unloaded module list
No unloaded module list present
Loading User Symbols




*
Bugcheck Analysis *
*



Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 80269b3c}

ERROR: Module load completed but symbols could not be loaded for
Aspi32.SYS
WARNING: Unable to verify checksum for WNASPI32.DLL
ERROR: Symbol file could not be found. Defaulted to export symbols
for WNASPI32.DLL - Probably caused by : passthru.sys (
passthru!DiskPerfPassThru+3b )

Followup: MachineOwner
---------

nt!RtlpBreakWithStatusInstruction:
80165c58 cc int 3
kd> !analyze -v



*
Bugcheck Analysis *
*
**********


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 80269b3c, address which referenced memory

Debugging Details:
------------------

READ_ADDRESS: 00000018

CURRENT_IRQL: 2

FAULTING_IP:
SCSIPORT!ScsiPortStartIo+101
80269b3c 8b4818 mov ecx,[eax+0x18]

DEFAULT_BUCKET_ID: DRIVER_FAULT

BUGCHECK_STR: 0xA

TRAP_FRAME: fcb29c30 – (.trap fffffffffcb29c30)
ErrCode = 00000000
eax=00000000 ebx=80911000 ecx=80913000 edx=00000000 esi=809160e0
edi=80823785
eip=80269b3c esp=fcb29ca4 ebp=fcb29cb8 iopl=0 nv up ei ng nz na
po
nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010286
SCSIPORT!ScsiPortStartIo+0x101:
80269b3c 8b4818 mov ecx,[eax+0x18]
Resetting default scope

LAST_CONTROL_TRANSFER: from 8011dd90 to 80269b3c

STACK_TEXT:
fcb29cb8 8011dd90 80916028 807d9008 80919a08
SCSIPORT!ScsiPortStartIo+0x101
fcb29cd8 802698d4 80916028 807d9008 00000000 nt!IoStartPacket+0x98
fcb29d08 8011c9a9 80916028 807d9008 8090c020
SCSIPORT!ScsiPortDispatch+0x363
fcb29d2c 800863db 00000008 8090c0d8 fcb29d60 nt!IofCallDriver+0x68
fcb29d3c 8011c9a9 8090c020 807d9008 808237bf
passthru!DiskPerfPassThru+0x3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
fcb29d60 f73ba252 807e4148 8084e598 8084e528 nt!IofCallDriver+0x68
WARNING: Stack unwind information not available. Following frames may be

wrong.
fcb29d98 f73b95ce 80826e08 807e4148 8084e528 Aspi32+0x2252
fcb29dc8 8011c9a9 80826d50 8084e528 807ab22c Aspi32+0x15ce
fcb29dec 801c18df 00133040 00133108 801ba801 nt!IofCallDriver+0x68
fcb29e08 801c222f 80826d50 8084e528 807abb68
nt!IopSynchronousServiceTail+0x9f
fcb29e94 801ba8e0 0000002c 00000020 00000000 nt!IopXxxControlFile+0x6f3
fcb29ec8 8017917a 0000002c 00000020 00000000
nt!NtDeviceIoControlFile+0x28

fcb29ec8 6720adfb 0000002c 00000020 00000000 nt!KiSystemService+0x10a
00f3fb7c 77f06695 0000002c 00000020 00000000
ntdll!ZwDeviceIoControlFile+0xb
00f3fbdc 00f424c9 0000002c 9090e080 00133040
KERNEL32!DeviceIoControl+0xb0

00133040 000000c8 00000001 00000100 0001a5e0 WNASPI32!WOWDispatch+0xe99

FOLLOWUP_IP:
passthru!DiskPerfPassThru+3b
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 137]
800863db 8945f8 mov [ebp-0x8],eax

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: passthru!DiskPerfPassThru+3b

MODULE_NAME: passthru

IMAGE_NAME: passthru.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 40a33502

STACK_COMMAND: .trap fffffffffcb29c30 ; kb

BUCKET_ID: 0xA_passthru!DiskPerfPassThru+3b

Followup: MachineOwner
---------

012345678901234567890123456789012345678901234567890123456789012345678

“Peter Wieland”
Sent by: xxxxx@lists.osr.com
05/13/2004 10:04 AM
Please respond to “Windows System Software Devs Interest List”

To: “Windows System Software Devs Interest List”

cc:
Subject: RE: [ntdev] NT4.0 SCSIPORT filter driver crash
only when ASPI32.SYS IRP is
passed down - simple passthru filter driver included

Wow.

Does it make any difference if you don’t increment the current location
and CurrentStackLocation? That seems like it should be benign but
perhaps it’s not.

ScsiPortConvertPhysicalAddressToUlong is pretty damned simple - I find
it hard to believe that it could be the actual cause of the problem.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@deadlinemavens.com
Sent: Wednesday, May 12, 2004 9:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NT4.0 SCSIPORT filter driver crash only when ASPI32.SYS
IRP is passed down - simple passthru filter driver included

Hello,

AT the moment i’m faced with a bizarre crash that occurs on NT 4.0 with
a SCSIPORT filter driver.

To get a better handle on this problem, i’ve stripped away all but just
enough to recreate this problem from development version of the SCSIPORT
filter driver i’m working on.

This sample is nothing more than a passthru SCSIPORT filter driver,
enough to reproduce the crash, consistently.

Bit of background is in order. The driver loads fine, attaches to
\Device\ScsiPort2 device object okay and i’m able to see that the
dispatch routine gets called as ASPI32.SYS sends down the internal IRP
to SCSIPORT for processing.

Note that this sample omits codes that handle the
SRB_FUNCTION_CLAIM_DEVICE so this sample will not filter SCSI I/O
requests from Windows SCSI disk class driver.

I have an ASPI-based SCSI test application that can send SCSI requests
that i can use to test this sample filter driver.

The problem comes up whenever i try to send SCSI command that involves
data read or write, eg. READ, INQUIRY, WRITE where it will crash the
system. Without the filter driver installed these commands work just
fine. Non-data commands such as TEST UNIT READY, START STOP UNIT, and
alike works okay.

I’m sure there’s something wrong with this simple passthru filter
driver, but i don’t see it.

All this passthru filter driver does is pass down the IRP. This driver
has a common dispatch routine for all IRP_MJ_XXX, and that dispatch
routine does nothing more than call the SCSIPORT driver passing down the
IRP that it received, for instance from ASPI32.SYS.

I have instrumented this sample driver with lots of debug prints that
dumps the IRP, I/O Stack and SRB parameter in the I/O Stack and even
used 3rd party application such as “DeviceFilter v2.2” to analyze for
potential bad values in them, but nothing so far.

All i know is that without this sample filter driver present, no crash,
but soon as filter driver is used to pass down the IRP from
DiskPerfPassThru dispatch to SCSIPORT, i get crash. And this dispatch
absolutely does no processing on IRP it gets. Simple passthru, that’s
all.

If anyone’s interested in more detail, feel free to ask and i can
provide whatever is needed.

So the question is, is there some sort of trick to be used to pass down
IRP_MJ_INTERNAL_DEVICE_CONTROL that has I/O control code of 0 with
SRB_FUNCTION_EXECUTE_SCSI to SCSIPORT?

Using development version of the SCSIPORT filter driver that also
filters SCSI disk class IRPs (that code is not shown in the sample here,
but if anyone’s interested i can share that too), going through the same
passthru mechanism, passing those IRPs down to SCSIPORT works fine.
Only from ASPI32.SYS i get the crash.

This is really bizzare…

I’m currently in conversation with Microsoft DDK support engineer and
we’ve gone few days exchanging phone conversations, notes, windbg
debugging, ideas, etc, with no success in trying to grasp the nature of
this crash. I’ve sent him a crash dump so hopefully that would shed
some insight into this problem.

I’ve included below few dumps from windbg if anyone’s interested.

Thanks much,

-gshin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

kd> k
ChildEBP RetAddr
fbf24d68 80111b3f passthru!DiskPerfPassThru+0x890
[C:\MSDN\NT4DDK\src\storage\filter\passthru\passthru.c @ 1705]
WARNING: Stack unwind information not available. Following frames may be
wrong.
fbf24db4 f73215ce nt!IofCallDriver+0x37
fbf24de4 80111b3f Aspi32+0x15ce
fbf24e14 8016fe12 nt!IofCallDriver+0x37 fbf24ea0 8016a194
nt!NtWriteFile+0x2584
fbf24ed4 8013e394 nt!NtDeviceIoControlFile+0x28
fbf24f04 00000000 nt!KiReleaseSpinLock+0x9c4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A fatal system error has occurred.

********************************************************
Symbols can not be loaded because symbol path is not initialized. *
*
The Symbol Path can be set by: *
using the _NT_SYMBOL_PATH environment variable. *
using the -y <symbol_path> argument when starting the debugger. *
using .sympath and .sympath+ *
******************************************************************
ERROR: Symbol file could not be found. Defaulted to export symbols
for ntoskrnl.exe -
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


Use !analyze -v to get detailed debugging information.

BugCheck A, {18, 2, 0, 801dbe19}

**Kernel symbols are WRONG. Please fix symbols to do analysis.

ERROR: Symbol file could not be found. Defaulted to export symbols
for SCSIPORT.SYS - Probably caused by : Unknown_Image (
SCSIPORT!ScsiPortConvertPhysicalAddressToUlong+3a5 )

Followup: MachineOwner
---------

nt!DbgBreakPointWithStatus+0x4:
8012ff7c cc int 3
kd> !analyze -v
**************************************************************


*
Bugcheck Analysis *
*
*****************************************************************


IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address

at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000018, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, value 0 = read operation, 1 = write operation
Arg4: 801dbe19, address which referenced memory

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include “ntddk.h”
#include “stdarg.h”
#include “stdio.h”
#include “ntdddisk.h”
#include “ntddscsi.h”
#include “srb.h”
#include “scsi.h”

#define FILE_DEVICE_PASSTHRU_FILTER 0x0000BEEF

//
// Remap DiskPerfDump to local routine.
//

#define DiskPerfDump(X) DiskPerfDebugPrint X

//
// Device Extension
//

typedef struct _DEVICE_EXTENSION
{

//
// Back pointer to device object
//

PDEVICE_OBJECT DeviceObject;

//
// Target Device Object
//

PDEVICE_OBJECT TargetDeviceObject;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)

//
// Function declarations
//

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

NTSTATUS
DiskPerfPassThru(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

VOID
DiskPerfDebugPrint(
ULONG DebugPrintLevel,
PCCHAR DebugMessage,

);

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PDEVICE_EXTENSION deviceExtension = NULL;
CCHAR ntNameBuffer[64];
STRING ntNameString;
UNICODE_STRING ntUnicodeString;
ULONG irpnum=0;

//
// Set up the device driver entry points.
//

for (irpnum=0; irpnum < IRP_MJ_MAXIMUM_FUNCTION+1; irpnum++)
{
DriverObject->MajorFunction[irpnum] = DiskPerfPassThru;
}

//
// Create unnamed Device Object and attach it to the Device Object
named

// \Device\ScsiPort2 Device Object created by the SCSI port driver.
//

status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_PASSTHRU_FILTER,
0,
FALSE,
&deviceObject);

deviceExtension = deviceObject->DeviceExtension;

//
// Create device name for the physical adapter driver. Note that in
// NTDDSCSI.H there’s a define, DD_SCSI_DEVICE_NAME that has the same
// Device Object name.
//

sprintf(ntNameBuffer, “\Device\ScsiPort2”);
RtlInitAnsiString(&ntNameString, ntNameBuffer);
RtlAnsiStringToUnicodeString(&ntUnicodeString, &ntNameString, TRUE);

status = IoAttachDevice(deviceObject,
&ntUnicodeString,
&deviceExtension->TargetDeviceObject);

RtlFreeUnicodeString(&ntUnicodeString);

return status;
} // DriverEntry

NTSTATUS
DiskPerfPassThru (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;

NTSTATUS status;

//
// Pass on this unrecognized I/O request down to SCSI Port driver,
i.e.
// SCSIPORT.
//

Irp->CurrentLocation++;
Irp->Tail.Overlay.CurrentStackLocation++;

status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);

return status;
} // end DiskPerfPassThru()

ULONG DiskPerfDebug = 3;

#if DBG
VOID
DiskPerfDebugPrint (
IN ULONG DebugPrintLevel,
IN PCCHAR DebugMessage,

)
{
va_list ap;

va_start( ap, DebugMessage );

if (DebugPrintLevel <= DiskPerfDebug)
{
char buffer[128];

vsprintf(buffer, DebugMessage, ap);
DbgPrint(buffer);
}

va_end(ap);

} // end DiskPerfDebugPrint

#endif // DBG


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@deadlinemavens.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</symbol_path>