- diff --git a/sys/nfs41sys_dir.c b/sys/nfs41sys_dir.c
- index 1e9f581..20a7574 100644
- --- a/sys/nfs41sys_dir.c
- +++ b/sys/nfs41sys_dir.c
- @@ -155,6 +155,7 @@ NTSTATUS unmarshal_nfs41_dirquery(
- code = GetExceptionCode();
- print_error("MmUnmapLockedPages thrown exception=0x%lx\n",
- (long)code);
- + cur->u.QueryFile.mdl_buf = NULL;
- status = STATUS_ACCESS_VIOLATION;
- }
- if (buf_len > cur->buf_len)
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index d90eb6d..53d1a89 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -322,6 +322,7 @@ NTSTATUS unmarshal_nfs41_queryallocatedranges(
- print_error("unmarshal_nfs41_queryallocatedranges: "
- "MmUnmapLockedPages thrown exception=0x%lx\n",
- (long)GetExceptionCode());
- + cur->u.QueryAllocatedRanges.Buffer = NULL;
- status = cur->status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index a5b5284..8884e91 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -259,6 +259,7 @@ NTSTATUS unmarshal_nfs41_open(
- } __except(EXCEPTION_EXECUTE_HANDLER) {
- print_error("MmUnmapLockedPages thrown exception=0x%lx\n",
- (long)GetExceptionCode());
- + cur->u.Open.EaBuffer = NULL;
- status = cur->status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
- index cc718df..8531a5f 100644
- --- a/sys/nfs41sys_readwrite.c
- +++ b/sys/nfs41sys_readwrite.c
- @@ -188,6 +188,7 @@ NTSTATUS unmarshal_nfs41_rw(
- code = GetExceptionCode();
- print_error("unmarshal_nfs41_rw: Call to MmUnmapLockedPages() "
- "failed due to exception 0x%0x\n", (long)code);
- + cur->buf = NULL;
- status = STATUS_ACCESS_VIOLATION;
- }
- #endif
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index 75801be..b69d34c 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -408,6 +408,7 @@ NTSTATUS nfs41_UpcallCreate(
- case NFS41_SYSOP_WRITE:
- case NFS41_SYSOP_READ:
- entry->buf = NULL;
- + entry->u.ReadWrite.MdlAddress = NULL;
- break;
- case NFS41_SYSOP_DIR_QUERY:
- entry->u.QueryFile.mdl_buf = NULL;
- @@ -434,13 +435,22 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- if (!entry)
- return;
- -#if defined(_DEBUG)
- +#if 1 /*defined(_DEBUG)*/
- switch(entry->opcode) {
- case NFS41_SYSOP_WRITE:
- case NFS41_SYSOP_READ:
- - if (entry->buf) {
- + if (entry->u.ReadWrite.MdlAddress && entry->buf) {
- DbgP("nfs41_UpcallDestroy: NFS41_SYSOP_RW mapping leak\n");
- - MmUnmapLockedPages(entry->buf, entry->u.ReadWrite.MdlAddress);
- + __try {
- + MmUnmapLockedPages(entry->buf, entry->u.ReadWrite.MdlAddress);
- + } __except(EXCEPTION_EXECUTE_HANDLER) {
- + NTSTATUS code;
- + code = GetExceptionCode();
- + print_error("nfs41_UpcallDestroy: "
- + "Call to MmUnmapLockedPages() "
- + "failed due to exception 0x%0x\n", (long)code);
- + }
- +
- entry->buf = NULL;
- }
- break;
- @@ -448,20 +458,42 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- if (entry->u.QueryFile.mdl) {
- DbgP("nfs41_UpcallDestroy: "
- "NFS41_SYSOP_DIR_QUERY mapping leak\n");
- - MmUnmapLockedPages(entry->u.QueryFile.mdl_buf,
- - entry->u.QueryFile.mdl);
- + if (entry->u.QueryFile.mdl_buf) {
- + __try {
- + MmUnmapLockedPages(entry->u.QueryFile.mdl_buf,
- + entry->u.QueryFile.mdl);
- + } __except(EXCEPTION_EXECUTE_HANDLER) {
- + NTSTATUS code;
- + code = GetExceptionCode();
- + print_error("nfs41_UpcallDestroy: "
- + "Call to MmUnmapLockedPages() "
- + "failed due to exception 0x%0x\n", (long)code);
- + }
- +
- + entry->u.QueryFile.mdl_buf = NULL;
- + }
- IoFreeMdl(entry->u.QueryFile.mdl);
- - entry->u.QueryFile.mdl_buf = NULL;
- entry->u.QueryFile.mdl = NULL;
- }
- break;
- case NFS41_SYSOP_OPEN:
- if (entry->u.Open.EaMdl) {
- DbgP("nfs41_UpcallDestroy: NFS41_SYSOP_OPEN mapping leak\n");
- - MmUnmapLockedPages(entry->u.Open.EaBuffer,
- - entry->u.Open.EaMdl);
- + if (entry->u.Open.EaBuffer) {
- + __try {
- + MmUnmapLockedPages(entry->u.Open.EaBuffer,
- + entry->u.Open.EaMdl);
- + } __except(EXCEPTION_EXECUTE_HANDLER) {
- + NTSTATUS code;
- + code = GetExceptionCode();
- + print_error("nfs41_UpcallDestroy: "
- + "Call to MmUnmapLockedPages() "
- + "failed due to exception 0x%0x\n", (long)code);
- + }
- +
- + entry->u.Open.EaBuffer = NULL;
- + }
- IoFreeMdl(entry->u.Open.EaMdl);
- - entry->u.Open.EaBuffer = NULL;
- entry->u.Open.EaMdl = NULL;
- }
- break;
- @@ -469,11 +501,21 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- if (entry->u.QueryAllocatedRanges.BufferMdl) {
- DbgP("nfs41_UpcallDestroy: "
- "NFS41_SYSOP_FSCTL_QUERYALLOCATEDRANGES mapping leak\n");
- - MmUnmapLockedPages(
- - entry->u.QueryAllocatedRanges.Buffer,
- - entry->u.QueryAllocatedRanges.BufferMdl);
- + if (entry->u.QueryAllocatedRanges.Buffer) {
- + __try {
- + MmUnmapLockedPages(
- + entry->u.QueryAllocatedRanges.Buffer,
- + entry->u.QueryAllocatedRanges.BufferMdl);
- + } __except(EXCEPTION_EXECUTE_HANDLER) {
- + NTSTATUS code;
- + code = GetExceptionCode();
- + print_error("nfs41_UpcallDestroy: Call to MmUnmapLockedPages() "
- + "failed due to exception 0x%0x\n", (long)code);
- + }
- +
- + entry->u.QueryAllocatedRanges.Buffer = NULL;
- + }
- IoFreeMdl(entry->u.QueryAllocatedRanges.BufferMdl);
- - entry->u.QueryAllocatedRanges.Buffer = NULL;
- entry->u.QueryAllocatedRanges.BufferMdl = NULL;
- }
- break;
nfs41_UpcallDestroy() crash fixes - does not work
Posted by Anonymous on Sat 10th May 2025 13:16
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.