- From dc5279b2ab6b75265921b901c8bfe116bddff084 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 18 Jul 2025 12:07:44 +0200
- Subject: [PATCH 1/2] sys: VolumeInformation queries should return
- |STATUS_BUFFER_OVERFLOW|+partial data if buffer is too small
- VolumeInformation queries should return |STATUS_BUFFER_OVERFLOW|+partial
- data if buffer is too small, as required by the Win32 spec.
- Previously we tried |STATUS_BUFFER_TOO_SMALL| and return the required
- buffer size (so that the caller can allocate a bigger buffer and then
- try again), but this caused the Visual Studio 2019 linker and
- $ '/cygdrive/c/Program Files/Git/cmd/git' clone ... # to fail.
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.h | 3 ++-
- sys/nfs41sys_fileinfo.c | 2 +-
- sys/nfs41sys_updowncall.c | 20 +++++++++++++++-----
- sys/nfs41sys_volinfo.c | 12 ++++++++----
- 4 files changed, 26 insertions(+), 11 deletions(-)
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 3057e25..a5cb6cd 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -827,7 +827,8 @@ void unmarshal_nfs41_attrget(
- nfs41_updowncall_entry *cur,
- PVOID attr_value,
- ULONG *attr_len,
- - unsigned char **buf);
- + unsigned char **buf,
- + BOOL copy_partial);
- NTSTATUS nfs41_UpcallCreate(
- IN DWORD opcode,
- IN PSECURITY_CLIENT_CONTEXT clnt_sec_ctx,
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index 36407f6..202e2fd 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -156,7 +156,7 @@ void unmarshal_nfs41_getattr(
- nfs41_updowncall_entry *cur,
- unsigned char **buf)
- {
- - unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf);
- + unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf, FALSE);
- RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- #ifdef DEBUG_MARSHAL_DETAIL
- if (cur->u.QueryFile.InfoClass == FileBasicInformation)
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index 9ec5382..7e113be 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -166,14 +166,24 @@ void unmarshal_nfs41_attrget(
- nfs41_updowncall_entry *cur,
- PVOID attr_value,
- ULONG *attr_len,
- - unsigned char **buf)
- + unsigned char **buf,
- + BOOL copy_partial)
- {
- ULONG buf_len;
- RtlCopyMemory(&buf_len, *buf, sizeof(ULONG));
- - if (buf_len > *attr_len) {
- - cur->status = STATUS_BUFFER_TOO_SMALL;
- - return;
- + if (copy_partial) {
- + if (buf_len > *attr_len) {
- + cur->status = STATUS_BUFFER_OVERFLOW;
- + buf_len = *attr_len;
- + }
- }
- + else {
- + if (buf_len > *attr_len) {
- + cur->status = STATUS_BUFFER_TOO_SMALL;
- + return;
- + }
- + }
- +
- *buf += sizeof(ULONG);
- *attr_len = buf_len;
- RtlCopyMemory(attr_value, *buf, buf_len);
- @@ -745,7 +755,7 @@ NTSTATUS nfs41_downcall(
- unmarshal_nfs41_symlink(cur, &buf);
- break;
- case NFS41_SYSOP_VOLUME_QUERY:
- - unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, &buf);
- + unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, &buf, TRUE);
- break;
- case NFS41_SYSOP_ACL_QUERY:
- status = unmarshal_nfs41_getacl(cur, &buf);
- diff --git a/sys/nfs41sys_volinfo.c b/sys/nfs41sys_volinfo.c
- index 1b1e470..182efcc 100644
- --- a/sys/nfs41sys_volinfo.c
- +++ b/sys/nfs41sys_volinfo.c
- @@ -203,10 +203,14 @@ NTSTATUS nfs41_QueryVolumeInformation(
- goto out;
- }
- - if (entry->status == STATUS_BUFFER_TOO_SMALL) {
- - RxContext->InformationToReturn = entry->buf_len;
- - status = STATUS_BUFFER_TOO_SMALL;
- - } else if (entry->status == STATUS_SUCCESS) {
- + if (entry->status == STATUS_BUFFER_OVERFLOW) {
- + /*
- + * Supplied buffer was too small, so we copied only part of
- + * the data into the buffer
- + */
- + status = STATUS_BUFFER_OVERFLOW;
- + }
- + else if (entry->status == STATUS_SUCCESS) {
- #ifdef ENABLE_TIMINGS
- InterlockedIncrement(&volume.sops);
- InterlockedAdd64(&volume.size, entry->u.Volume.buf_len);
- --
- 2.45.1
- From d4de60c0ec48238977a8491c12b9cf64daf9b66a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 18 Jul 2025 13:58:16 +0200
- Subject: [PATCH 2/2] daemon: Increase size limit for EAs to 8192
- Increase size limit for EAs from 2048 to 8192.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/ea.c | 8 ++++++++
- daemon/nfs41_const.h | 2 +-
- 2 files changed, 9 insertions(+), 1 deletion(-)
- diff --git a/daemon/ea.c b/daemon/ea.c
- index b9e68b7..a1fb42f 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -32,6 +32,14 @@
- #include "daemon_debug.h"
- #include "nfs_ea.h"
- +/*
- + * Compile safeguard to see whether |NFS4_EASIZE+header| will still fit into
- + * |UPCALL_BUF_SIZE|
- + */
- +#if (NFS4_EASIZE+1024) > UPCALL_BUF_SIZE
- +#error NFS4_EASIZE does not fit into UPCALL_BUF_SIZE
- +#endif
- +
- /*
- * |WIN_NFS4_EA_NAME_PREFIX| - Prefix for Windows EA in NFSv4
- * XATTR (extended attributes) namespace
- diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
- index 524dd30..9ce6692 100644
- --- a/daemon/nfs41_const.h
- +++ b/daemon/nfs41_const.h
- @@ -42,7 +42,7 @@
- #define NFS4_OPAQUE_LIMIT_ATTR (8192)
- #define NFS4_SESSIONID_SIZE 16
- #define NFS4_STATEID_OTHER 12
- -#define NFS4_EASIZE 2048
- +#define NFS4_EASIZE 8192
- #define NFS4_EANAME_SIZE 128
- #define NFSD_THREAD_STACK_SIZE (4*1024*1024)
- --
- 2.45.1
msnfs41client: Patches for QueryVolumeInformation-should-return-STATUS_BUFFER_OVERFLOW, increase EA size, 2025-07-18
Posted by Anonymous on Fri 18th Jul 2025 13:22
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.