- From 3c2f4639ffd39aec610e631a70a95af633c65e24 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Mon, 22 Sep 2025 11:29:24 +0200
- Subject: [PATCH 1/4] sys: |nfs41_UpcallDestroy()| should clear event per
- Windows API spec
- |nfs41_UpcallDestroy()| should clear event per Windows API spec.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_updowncall.c | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index f629266..749d892 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -497,6 +497,8 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- }
- #endif /* _DEBUG */
- + KeClearEvent(&entry->cond);
- +
- if (entry->psec_ctx_clienttoken) {
- ObDereferenceObject(entry->psec_ctx_clienttoken);
- }
- --
- 2.51.0
- From f38099d996d0667ae06a846472d20c5d90b22b42 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Mon, 22 Sep 2025 11:36:55 +0200
- Subject: [PATCH 2/4] sys: Remove disabled |MmUnmapLockedPages()| code from
- |nfs41_UpcallDestroy()|
- Remove disabled |MmUnmapLockedPages()| code from |nfs41_UpcallDestroy()|,
- it could've never worked that way anyway because process pages can
- only be unmapped in the context of the same process. That's why
- $ verifier /standard /driver nfs41_driver.sys # triggered a kernel assert.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_updowncall.c | 52 ---------------------------------------
- 1 file changed, 52 deletions(-)
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index 749d892..5066c99 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -445,58 +445,6 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- if (!entry)
- return;
- - /*
- - * Free resources which might otherwise be leaked
- - * FIXME: Does not work yet, the |NFS41_SYSOP_READ| codepath crashes in
- - * |MmUnmapLockedPages()| when
- - * $ verifier /standard /driver nfs41_driver.sys # is active
- - */
- -#ifdef XXDISABLED_FOR_NOWXX /*defined(_DEBUG) */
- - switch(entry->opcode) {
- - case NFS41_SYSOP_WRITE:
- - case NFS41_SYSOP_READ:
- - if (entry->buf) {
- - DbgP("nfs41_UpcallDestroy: NFS41_SYSOP_RW mapping leak\n");
- - MmUnmapLockedPages(entry->buf, entry->u.ReadWrite.MdlAddress);
- - entry->buf = NULL;
- - }
- - break;
- - case NFS41_SYSOP_DIR_QUERY:
- - 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);
- - 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);
- - IoFreeMdl(entry->u.Open.EaMdl);
- - entry->u.Open.EaBuffer = NULL;
- - entry->u.Open.EaMdl = NULL;
- - }
- - break;
- - case NFS41_SYSOP_FSCTL_QUERYALLOCATEDRANGES:
- - if (entry->u.QueryAllocatedRanges.BufferMdl) {
- - DbgP("nfs41_UpcallDestroy: "
- - "NFS41_SYSOP_FSCTL_QUERYALLOCATEDRANGES mapping leak\n");
- - MmUnmapLockedPages(
- - entry->u.QueryAllocatedRanges.Buffer,
- - entry->u.QueryAllocatedRanges.BufferMdl);
- - IoFreeMdl(entry->u.QueryAllocatedRanges.BufferMdl);
- - entry->u.QueryAllocatedRanges.Buffer = NULL;
- - entry->u.QueryAllocatedRanges.BufferMdl = NULL;
- - }
- - break;
- - }
- -#endif /* _DEBUG */
- -
- KeClearEvent(&entry->cond);
- if (entry->psec_ctx_clienttoken) {
- --
- 2.51.0
- From 1730aa5edc0433cb37e0cbdfff04bc9d470329cf Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 22 Sep 2025 15:42:36 +0200
- Subject: [PATCH 3/4] sys: |nfs41_DuplicateData()| should flush the source file
- before cloning
- |nfs41_DuplicateData()| should flush the source file before cloning.
- This should make sure that the NFS server (which is doing the block
- cloning) sees the same data as the client, even if the client was writing
- into the same handle as is used for cloning.
- Reported-by: Dan Shelton <dan.f.shelton@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_fsctl.c | 20 ++++++++++++++++++++
- 1 file changed, 20 insertions(+)
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 16edecb..488db88 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -754,6 +754,26 @@ NTSTATUS nfs41_DuplicateData(
- goto out;
- }
- + IO_STATUS_BLOCK flushIoStatus;
- + DbgP("nfs41_DuplicateData: flushing src file buffers\n");
- + status = ZwFlushBuffersFile(dd.handle, &flushIoStatus);
- + if (status) {
- + if (status == STATUS_ACCESS_DENIED) {
- + /*
- + * |ZwFlushBuffersFile()| can fail if |dd.handle| was not opened
- + * for write access
- + */
- + DbgP("nfs41_DuplicateData: "
- + "ZwFlushBuffersFile() failed with STATUS_ACCESS_DENIED\n");
- + }
- + else {
- + DbgP("nfs41_DuplicateData: "
- + "ZwFlushBuffersFile() failed, status=0x%lx\n",
- + (long)status);
- + goto out;
- + }
- + }
- +
- /*
- * Disable caching because NFSv4.2 DEALLOCATE is basically a
- * "write" operation. AFAIK we should flush the cache and wait
- --
- 2.51.0
- From 1d90c864fa4e40607a5d2046793fbc76c683d498 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 22 Sep 2025 15:45:31 +0200
- Subject: [PATCH 4/4] sys: Fix comment s/NFSv4.2 DEALLOCATE/NFSv4.2 CLONE/ in
- |nfs41_DuplicateData()|
- Fix comment s/NFSv4.2 DEALLOCATE/NFSv4.2 CLONE/ in |nfs41_DuplicateData()|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_fsctl.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 488db88..b65d35b 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -775,12 +775,12 @@ NTSTATUS nfs41_DuplicateData(
- }
- /*
- - * Disable caching because NFSv4.2 DEALLOCATE is basically a
- + * Disable caching because NFSv4.2 CLONE is basically a
- * "write" operation. AFAIK we should flush the cache and wait
- * for the kernel lazy writer (which |RxChangeBufferingState()|
- - * AFAIK does) before doing the DEALLOCATE, to avoid that we
- + * AFAIK does) before doing the CLONE, to avoid that we
- * have outstanding writes in the kernel cache at the same
- - * location where the DEALLOCATE should do it's work
- + * location where the CLONE should do it's work
- */
- ULONG flag = DISABLE_CACHING;
- DbgP("nfs41_DuplicateData: disableing caching for file '%wZ'\n",
- --
- 2.51.0
msnfs41client: Patch for flushing src buffers before cloning, cleanup+misc, 2025-09-22
Posted by Anonymous on Mon 22nd Sep 2025 15:00
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.