Author: tfaber Date: Thu Jul 28 09:00:56 2011 New Revision: 52947
URL: http://svn.reactos.org/svn/reactos?rev=52947&view=rev Log: [KMTESTS] - probe user address in user mode - don't free the result buffer before the driver unlocks it. Fixes assertion in ROS for large buffers
Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/in... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] Thu Jul 28 09:00:56 2011 @@ -173,15 +173,17 @@
INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0); #elif defined KMT_USER_MODE -static PKMT_RESULTBUFFER KmtAllocateResultBuffer(SIZE_T LogBufferMaxLength) -{ - PKMT_RESULTBUFFER Buffer = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LogBufferMaxLength])); +static PKMT_RESULTBUFFER KmtAllocateResultBuffer(SIZE_T ResultBufferSize) +{ + PKMT_RESULTBUFFER Buffer = HeapAlloc(GetProcessHeap(), 0, ResultBufferSize); + if (!Buffer) + return NULL;
Buffer->Successes = 0; Buffer->Failures = 0; Buffer->Skipped = 0; Buffer->LogBufferLength = 0; - Buffer->LogBufferMaxLength = LogBufferMaxLength; + Buffer->LogBufferMaxLength = ResultBufferSize - FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer);
return Buffer; }
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c [iso-8859-1] Thu Jul 28 09:00:56 2011 @@ -24,8 +24,7 @@ #define SERVICE_PATH L"kmtest_drv.sys" #define SERVICE_DESCRIPTION L"ReactOS Kernel-Mode Test Suite Driver"
-#define LOGBUFFER_SIZE 16364 -#define RESULTBUFFER_SIZE FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LOGBUFFER_SIZE]) +#define RESULTBUFFER_SIZE (1024 * 1024)
typedef enum { @@ -255,9 +254,14 @@
assert(TestName != NULL);
- ResultBuffer = KmtAllocateResultBuffer(LOGBUFFER_SIZE); - if (!DeviceIoControl(KmtestHandle, IOCTL_KMTEST_SET_RESULTBUFFER, ResultBuffer, RESULTBUFFER_SIZE, NULL, 0, &BytesRead, NULL)) - error_goto(Error, cleanup); + if (!ResultBuffer) + { + ResultBuffer = KmtAllocateResultBuffer(RESULTBUFFER_SIZE); + if (!ResultBuffer) + error_goto(Error, cleanup); + if (!DeviceIoControl(KmtestHandle, IOCTL_KMTEST_SET_RESULTBUFFER, ResultBuffer, RESULTBUFFER_SIZE, NULL, 0, &BytesRead, NULL)) + error_goto(Error, cleanup); + }
// check test list TestFunction = FindTest(TestName); @@ -274,8 +278,6 @@ cleanup: if (!Error) Error = OutputResult(TestName); - - KmtFreeResultBuffer(ResultBuffer);
return Error; } @@ -367,6 +369,9 @@ if (KmtestHandle) CloseHandle(KmtestHandle);
+ if (ResultBuffer) + KmtFreeResultBuffer(ResultBuffer); + KmtCloseService(&KmtestServiceHandle);
if (Error)
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c [iso-8859-1] Thu Jul 28 09:00:56 2011 @@ -314,9 +314,10 @@ { PKMT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
- DPRINT("DriverIoControl. IOCTL_KMTEST_SET_RESULTBUFFER, inlen=%lu, outlen=%lu\n", - IoStackLocation->Parameters.DeviceIoControl.InputBufferLength, - IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength); + DPRINT("DriverIoControl. IOCTL_KMTEST_SET_RESULTBUFFER, buffer=%p, inlen=%lu, outlen=%lu\n", + IoStackLocation->Parameters.DeviceIoControl.Type3InputBuffer, + IoStackLocation->Parameters.DeviceIoControl.InputBufferLength, + IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
if (DeviceExtension->Mdl) { @@ -342,7 +343,7 @@
_SEH2_TRY { - MmProbeAndLockPages(DeviceExtension->Mdl, KernelMode, IoModifyAccess); + MmProbeAndLockPages(DeviceExtension->Mdl, UserMode, IoModifyAccess); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {