[driver] verifier raised issues with mdls

it complained that mdls had to have a certain (undocumented) flag set.
also, it seemed to imply that in readdir, the locking of pages needed
to be done by the thread creating the mdl. so i moved the locking/unlocking
there.
This commit is contained in:
Olga Kornievskaia 2011-10-06 12:32:50 -04:00
parent b3e4953890
commit 65c6091f69

View file

@ -686,6 +686,7 @@ NTSTATUS marshal_nfs41_rw(nfs41_updowncall_entry *entry,
RtlCopyMemory(tmp, &entry->u.ReadWrite.offset, sizeof(entry->u.ReadWrite.offset)); RtlCopyMemory(tmp, &entry->u.ReadWrite.offset, sizeof(entry->u.ReadWrite.offset));
tmp += sizeof(entry->u.ReadWrite.offset); tmp += sizeof(entry->u.ReadWrite.offset);
__try { __try {
entry->u.ReadWrite.MdlAddress->MdlFlags |= MDL_MAPPING_CAN_FAIL;
entry->u.ReadWrite.buf = entry->u.ReadWrite.buf =
MmMapLockedPagesSpecifyCache(entry->u.ReadWrite.MdlAddress, MmMapLockedPagesSpecifyCache(entry->u.ReadWrite.MdlAddress,
UserMode, MmNonCached, NULL, TRUE, NormalPagePriority); UserMode, MmNonCached, NULL, TRUE, NormalPagePriority);
@ -876,7 +877,6 @@ NTSTATUS marshal_nfs41_dirquery(nfs41_updowncall_entry *entry,
RtlCopyMemory(tmp, &entry->u.QueryFile.return_single, sizeof(BOOLEAN)); RtlCopyMemory(tmp, &entry->u.QueryFile.return_single, sizeof(BOOLEAN));
tmp += sizeof(BOOLEAN); tmp += sizeof(BOOLEAN);
__try { __try {
MmProbeAndLockPages(entry->u.QueryFile.mdl, KernelMode, IoModifyAccess);
entry->u.QueryFile.mdl_buf = entry->u.QueryFile.mdl_buf =
MmMapLockedPagesSpecifyCache(entry->u.QueryFile.mdl, MmMapLockedPagesSpecifyCache(entry->u.QueryFile.mdl,
UserMode, MmNonCached, NULL, TRUE, NormalPagePriority); UserMode, MmNonCached, NULL, TRUE, NormalPagePriority);
@ -1524,6 +1524,7 @@ nfs41_downcall (
while (pEntry != NULL) { while (pEntry != NULL) {
cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry, cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry,
nfs41_updowncall_entry, next); nfs41_updowncall_entry, next);
DbgP("nfs41_downcall: comparing %d %d\n", cur->xid, tmp->xid);
if (cur->xid == tmp->xid) { if (cur->xid == tmp->xid) {
found = 1; found = 1;
break; break;
@ -1619,7 +1620,6 @@ nfs41_downcall (
buf += sizeof(ULONG); buf += sizeof(ULONG);
__try { __try {
MmUnmapLockedPages(cur->u.QueryFile.mdl_buf, cur->u.QueryFile.mdl); MmUnmapLockedPages(cur->u.QueryFile.mdl_buf, cur->u.QueryFile.mdl);
MmUnlockPages(cur->u.QueryFile.mdl);
} __except(EXCEPTION_EXECUTE_HANDLER) { } __except(EXCEPTION_EXECUTE_HANDLER) {
NTSTATUS code; NTSTATUS code;
code = GetExceptionCode(); code = GetExceptionCode();
@ -3658,6 +3658,8 @@ NTSTATUS nfs41_QueryDirectory (
RxFreePool(entry); RxFreePool(entry);
goto out; goto out;
} }
entry->u.QueryFile.mdl->MdlFlags |= MDL_MAPPING_CAN_FAIL;
MmProbeAndLockPages(entry->u.QueryFile.mdl, KernelMode, IoModifyAccess);
entry->u.QueryFile.filter = Filter; entry->u.QueryFile.filter = Filter;
entry->u.QueryFile.initial_query = RxContext->QueryDirectory.InitialQuery; entry->u.QueryFile.initial_query = RxContext->QueryDirectory.InitialQuery;
@ -3668,6 +3670,7 @@ NTSTATUS nfs41_QueryDirectory (
status = STATUS_INTERNAL_ERROR; status = STATUS_INTERNAL_ERROR;
goto out; goto out;
} }
MmUnlockPages(entry->u.QueryFile.mdl);
if (entry->status == STATUS_BUFFER_TOO_SMALL) { if (entry->status == STATUS_BUFFER_TOO_SMALL) {
print_error("ERROR: buffer too small provided %d need %d\n", print_error("ERROR: buffer too small provided %d need %d\n",