- From 4c321e5efeffd1273fae6961e544b59c78754bf3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 19 Dec 2024 11:56:24 +0100
- Subject: [PATCH 1/3] sys: Add |PagedPool| support to our version of the
- |RxAllocatePoolWithTag()| macro
- Add |PagedPool| support to our |ExAllocatePool2()|-based version of the
- |RxAllocatePoolWithTag()| macro.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.h | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 1c39ab6..0e0107c 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -48,8 +48,10 @@
- (POOL_FLAG_UNINITIALIZED|POOL_FLAG_CACHE_ALIGNED)
- #define RxAllocatePoolWithTag(rxallocpool, numbytes, tag) \
- - ExAllocatePool2(((((rxallocpool) == NonPagedPoolNx)? \
- - POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE) | \
- + ExAllocatePool2((( \
- + ((rxallocpool) == PagedPool)?POOL_FLAG_PAGED: \
- + (((rxallocpool) == NonPagedPoolNx)? \
- + POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE)) | \
- RXALLOCATEPOOL_DEFAULT_ALLOCATEPOOL2FLAGS), \
- (numbytes), (tag))
- #endif /* EXALLOCATEPOOLWITHTAG_DEPRECATED */
- --
- 2.45.1
- From e583e149fb36ced6d8ee83f7a60c79a092ffe252 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 19 Dec 2024 12:19:41 +0100
- Subject: [PATCH 2/3] sys,tests: File open with write-only desired access
- should turn-off write caching
- File open with write-only desired access should turn-off write caching,
- otherwise we might end-up with blocks of zero-bytes in the file instead
- of valid data.
- This fixes issues with tools like Win10 /cygdrive/c/Windows/system32/tar,
- which uses write-only handles and had $'\0'-bytes in plain text files
- when unpacking files.
- Testing:
- If we do not turn off write caching in this case "wintartest_seq001.bash"
- will fail like this (might require a few hundred cycles, and only fails
- on a freshly booted machine, e.g. this bug includes a race-condition!):
- -------- snip --------
- x 1seq.txt
- x 100seq.txt
- x 1040seq.txt
- x 5000seq.txt
- x 10000seq.txt
- x 12000seq.txt
- x 1seq.txt
- x 100seq.txt
- x 1040seq.txt
- x 5000seq.txt
- x 10000seq.txt
- x 12000seq.txt
- ---- snip ----
- 000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- 000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- 000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- 000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- 000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- ---- snip ----
- -------- snip --------
- Thanks to Hermes Belusca-Maito <hermes.belusca-maito@reactos.org>
- for helping a lot to hunt this bug down.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_openclose.c | 22 ++++++++++++++++++++++
- tests/manual_testing.txt | 34 +++++++++++++++++++++++++++++++++-
- 2 files changed, 55 insertions(+), 1 deletion(-)
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index 86473e5..794aeee 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -333,6 +333,15 @@ static BOOLEAN isOpen2Create(
- return FALSE;
- }
- +static BOOLEAN isWriteOnlyDesiredAccess(PNT_CREATE_PARAMETERS params)
- +{
- + if (((params->DesiredAccess & (FILE_EXECUTE|FILE_READ_DATA)) == 0) &&
- + ((params->DesiredAccess & (FILE_WRITE_DATA|FILE_APPEND_DATA)) != 0)) {
- + return TRUE;
- + }
- + return FALSE;
- +}
- +
- static BOOLEAN areOpenParamsValid(NT_CREATE_PARAMETERS *params)
- {
- /* from ms-fsa page 52 */
- @@ -851,6 +860,19 @@ retry_on_link:
- #ifdef DEBUG_OPEN
- DbgP("nfs41_Create: received delegation %d\n", entry->u.Open.deleg_type);
- #endif
- +
- + /*
- + * We cannot have a file cached on a write-only handle,
- + * so we have to set |SRVOPEN_FLAG_DONTUSE_WRITE_CACHING|
- + * in this case.
- + */
- + if (isWriteOnlyDesiredAccess(params)) {
- + SrvOpen->Flags |= SRVOPEN_FLAG_DONTUSE_WRITE_CACHING;
- + DbgP("nfs41_Create: write-only handle for file '%wZ', "
- + "setting SRVOPEN_FLAG_DONTUSE_WRITE_CACHING\n",
- + SrvOpen->pAlreadyPrefixedName);
- + }
- +
- if (!(params->CreateOptions & FILE_WRITE_THROUGH) &&
- !pVNetRootContext->write_thru &&
- (entry->u.Open.deleg_type == 2 ||
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index 48614f2..6ee7186 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -1,5 +1,5 @@
- #
- -# ms-nfs41-client manual testing sequence, 2024-07-04
- +# ms-nfs41-client manual testing sequence, 2024-12-19
- #
- # Draft version, needs to be turned into automated tests
- # if possible
- @@ -456,6 +456,38 @@ drmemory -batch -check_uninit_all -strict_bitops -logdir "$(cygpath -w "$PWD")"
- # Run Windows tar (/cygdrive/c/Windows/system32/tar) tests
- # on NFSv4.1 filesystem
- #
- +# Notes:
- +# - Win10 /cygdrive/c/Windows/system32/tar uses write-only handles
- +# which should turn-off write caching. If we do not turn off
- +# write caching in this case "wintartest_seq001.bash" will fail
- +# like this (might require a few hundred cycles, and only fails
- +# on a freshly booted machine):
- +# -------- snip --------
- +# #### Test cycle 11 (usingbzip=true,tarfileonlocaldisk=true):
- +# x 1seq.txt
- +# x 100seq.txt
- +# x 1040seq.txt
- +# x 5000seq.txt
- +# x 10000seq.txt
- +# x 12000seq.txt
- +# #### Test cycle 12 (usingbzip=true,tarfileonlocaldisk=true):
- +# x 1seq.txt
- +# x 100seq.txt
- +# x 1040seq.txt
- +# x 5000seq.txt
- +# x 10000seq.txt
- +# x 12000seq.txt
- +# ## ERROR: Zero byte in plain /usr/bin/seq output 10000seq.txt found:
- +# ---- snip ----
- +# 000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- +# 000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- +# 000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- +# 000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- +# 000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- +# ---- snip ----
- +# -------- snip --------
- +#
- +#
- cd /cygdrive/n/xxx/
- bash /usr/share/msnfs41client/tests/misc/wintartests/wintartest_seq001.bash
- --
- 2.45.1
- From 8be4753af5e39b365584c71dbaa1820ee520cbc3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 19 Dec 2024 12:50:39 +0100
- Subject: [PATCH 3/3] sys: Fix locked page+memory "leaks" in
- |nfs41_QueryDirectory()|+|nfs41_Create()| error codepaths
- Fix locked page+memory "leaks" in |nfs41_QueryDirectory()| and
- |nfs41_Create()| error codepaths.
- Reported-by: Hermes Belusca-Maito <hermes.belusca-maito@reactos.org>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_dir.c | 4 +++-
- sys/nfs41sys_openclose.c | 4 +++-
- 2 files changed, 6 insertions(+), 2 deletions(-)
- diff --git a/sys/nfs41sys_dir.c b/sys/nfs41sys_dir.c
- index 815904a..fee2847 100644
- --- a/sys/nfs41sys_dir.c
- +++ b/sys/nfs41sys_dir.c
- @@ -288,9 +288,11 @@ NTSTATUS nfs41_QueryDirectory(
- entry->u.QueryFile.return_single = RxContext->QueryDirectory.ReturnSingleEntry;
- status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
- - if (status) goto out;
- +
- MmUnlockPages(entry->u.QueryFile.mdl);
- + if (status) goto out;
- +
- if (entry->status == STATUS_BUFFER_TOO_SMALL) {
- DbgP("nfs41_QueryDirectory: buffer too small provided %d need %lu\n",
- RxContext->Info.LengthRemaining, entry->buf_len);
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index 794aeee..d2624e7 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -690,17 +690,19 @@ retry_on_link:
- }
- status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
- +
- if (entry->psec_ctx == &entry->sec_ctx) {
- SeDeleteClientSecurity(entry->psec_ctx);
- }
- entry->psec_ctx = NULL;
- - if (status) goto out;
- if (entry->u.Open.EaMdl) {
- MmUnlockPages(entry->u.Open.EaMdl);
- IoFreeMdl(entry->u.Open.EaMdl);
- }
- + if (status) goto out;
- +
- if (entry->status == NO_ERROR && entry->errno == ERROR_REPARSE) {
- /* symbolic link handling. when attempting to open a symlink when the
- * FILE_OPEN_REPARSE_POINT flag is not set, replace the filename with
- --
- 2.45.1
msnfs41client: Patches for handling write-only open requests, fix pagelock+mem leaks+misc, 2024-12-19
Posted by Anonymous on Thu 19th Dec 2024 12:44
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.