Skip to content

Commit

Permalink
release spin lock before accessing *SetTokenObjectType
Browse files Browse the repository at this point in the history
git-svn-id: http://dokan.googlecode.com/svn/trunk@146 53ea604a-054e-0410-8546-456bafaea6b0
  • Loading branch information
asakaw committed Apr 10, 2010
1 parent 6b37404 commit 46f7936
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 14 additions & 3 deletions sys/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.

#include "dokan.h"

extern POBJECT_TYPE * SeTokenObjectType;

NTSTATUS
DokanGetAccessToken(
__in PDEVICE_OBJECT DeviceObject,
Expand All @@ -32,15 +34,14 @@ DokanGetAccessToken(
PDokanVCB vcb;
PEVENT_INFORMATION eventInfo;
PACCESS_TOKEN accessToken;
NTSTATUS status;
NTSTATUS status = STATUS_INVALID_PARAMETER;
HANDLE handle;
PIO_STACK_LOCATION irpSp = NULL;
BOOLEAN hasLock = FALSE;
ULONG outBufferLen;
ULONG inBufferLen;
PACCESS_STATE accessState;


DDbgPrint("==> DokanGetAccessToken\n");

__try {
Expand Down Expand Up @@ -91,13 +92,23 @@ DokanGetAccessToken(
accessState = irpEntry->IrpSp->Parameters.Create.SecurityContext->AccessState;
break;
}
KeReleaseSpinLock(&vcb->Dcb->PendingIrp.ListLock, oldIrql);
hasLock = FALSE;

if (accessState == NULL) {
DDbgPrint(" can't find pending Irp: %d\n", eventInfo->SerialNumber);
__leave;
}

accessToken = SeQuerySubjectContextToken(&accessState->SubjectSecurityContext);
status = ObOpenObjectByPointer(accessToken, 0, NULL, GENERIC_ALL, *SeTokenObjectType, KernelMode, &handle);
if (accessToken == NULL) {
DDbgPrint(" accessToken == NULL\n");
__leave;
}
// NOTE: Accessing *SeTokenObjectType while acquring sping lock causes
// BSOD on Windows XP.
status = ObOpenObjectByPointer(accessToken, 0, NULL, GENERIC_ALL,
*SeTokenObjectType, KernelMode, &handle);
if (!NT_SUCCESS(status)) {
DDbgPrint(" ObOpenObjectByPointer failed: 0x%x\n", status);
__leave;
Expand Down
14 changes: 4 additions & 10 deletions sys/dokan.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
//

#define DOKAN_DEBUG_DEFAULT 1
//#define USE_DBGPRINT 1

extern ULONG g_Debug;

Expand Down Expand Up @@ -73,17 +72,12 @@ extern ULONG g_Debug;

#define DOKAN_KEEPALIVE_TIMEOUT (1000 * 15) // in millisecond

#ifdef USE_DBGPRINT
#if _WIN32_NT > 0x501
#define DDbgPrint(...) \
if (g_Debug) { DbgPrint("[DokanFS] " __VA_ARGS__); }
#else
#if _WIN32_WINNT >= 0x0501
#define DDbgPrint(...) \
if (g_Debug) { KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL, "[DokanFS] " __VA_ARGS__ )); }
#else
#define DDbgPrint(...) \
if (g_Debug) { KdPrint(("[DokanFS] " __VA_ARGS__)); }
#endif
#else
#define DDbgPrint(...) \
if (g_Debug) { DbgPrint("[DokanFS] " __VA_ARGS__); }
#endif

#if _WIN32_WINNT < 0x0501
Expand Down

0 comments on commit 46f7936

Please sign in to comment.