pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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

  1. From dc5279b2ab6b75265921b901c8bfe116bddff084 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 18 Jul 2025 12:07:44 +0200
  4. Subject: [PATCH 1/2] sys: VolumeInformation queries should return
  5.  |STATUS_BUFFER_OVERFLOW|+partial data if buffer is too small
  6.  
  7. VolumeInformation queries should return |STATUS_BUFFER_OVERFLOW|+partial
  8. data if buffer is too small, as required by the Win32 spec.
  9.  
  10. Previously we tried |STATUS_BUFFER_TOO_SMALL| and return the required
  11. buffer size (so that the caller can allocate a bigger buffer and then
  12. try again), but this caused the Visual Studio 2019 linker and
  13. $ '/cygdrive/c/Program Files/Git/cmd/git' clone ... # to fail.
  14.  
  15. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  16. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  17. ---
  18. sys/nfs41sys_driver.h     |  3 ++-
  19.  sys/nfs41sys_fileinfo.c   |  2 +-
  20.  sys/nfs41sys_updowncall.c | 20 +++++++++++++++-----
  21.  sys/nfs41sys_volinfo.c    | 12 ++++++++----
  22.  4 files changed, 26 insertions(+), 11 deletions(-)
  23.  
  24. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  25. index 3057e25..a5cb6cd 100644
  26. --- a/sys/nfs41sys_driver.h
  27. +++ b/sys/nfs41sys_driver.h
  28. @@ -827,7 +827,8 @@ void unmarshal_nfs41_attrget(
  29.      nfs41_updowncall_entry *cur,
  30.      PVOID attr_value,
  31.      ULONG *attr_len,
  32. -    unsigned char **buf);
  33. +    unsigned char **buf,
  34. +    BOOL copy_partial);
  35.  NTSTATUS nfs41_UpcallCreate(
  36.      IN DWORD opcode,
  37.      IN PSECURITY_CLIENT_CONTEXT clnt_sec_ctx,
  38. diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
  39. index 36407f6..202e2fd 100644
  40. --- a/sys/nfs41sys_fileinfo.c
  41. +++ b/sys/nfs41sys_fileinfo.c
  42. @@ -156,7 +156,7 @@ void unmarshal_nfs41_getattr(
  43.      nfs41_updowncall_entry *cur,
  44.      unsigned char **buf)
  45.  {
  46. -    unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf);
  47. +    unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf, FALSE);
  48.      RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
  49.  #ifdef DEBUG_MARSHAL_DETAIL
  50.      if (cur->u.QueryFile.InfoClass == FileBasicInformation)
  51. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  52. index 9ec5382..7e113be 100644
  53. --- a/sys/nfs41sys_updowncall.c
  54. +++ b/sys/nfs41sys_updowncall.c
  55. @@ -166,14 +166,24 @@ void unmarshal_nfs41_attrget(
  56.      nfs41_updowncall_entry *cur,
  57.      PVOID attr_value,
  58.      ULONG *attr_len,
  59. -    unsigned char **buf)
  60. +    unsigned char **buf,
  61. +    BOOL copy_partial)
  62.  {
  63.      ULONG buf_len;
  64.      RtlCopyMemory(&buf_len, *buf, sizeof(ULONG));
  65. -    if (buf_len > *attr_len) {
  66. -        cur->status = STATUS_BUFFER_TOO_SMALL;
  67. -        return;
  68. +    if (copy_partial) {
  69. +        if (buf_len > *attr_len) {
  70. +            cur->status = STATUS_BUFFER_OVERFLOW;
  71. +            buf_len = *attr_len;
  72. +        }
  73.      }
  74. +    else {
  75. +        if (buf_len > *attr_len) {
  76. +            cur->status = STATUS_BUFFER_TOO_SMALL;
  77. +            return;
  78. +        }
  79. +    }
  80. +
  81.      *buf += sizeof(ULONG);
  82.      *attr_len = buf_len;
  83.      RtlCopyMemory(attr_value, *buf, buf_len);
  84. @@ -745,7 +755,7 @@ NTSTATUS nfs41_downcall(
  85.              unmarshal_nfs41_symlink(cur, &buf);
  86.              break;
  87.          case NFS41_SYSOP_VOLUME_QUERY:
  88. -            unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, &buf);
  89. +            unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, &buf, TRUE);
  90.              break;
  91.          case NFS41_SYSOP_ACL_QUERY:
  92.              status = unmarshal_nfs41_getacl(cur, &buf);
  93. diff --git a/sys/nfs41sys_volinfo.c b/sys/nfs41sys_volinfo.c
  94. index 1b1e470..182efcc 100644
  95. --- a/sys/nfs41sys_volinfo.c
  96. +++ b/sys/nfs41sys_volinfo.c
  97. @@ -203,10 +203,14 @@ NTSTATUS nfs41_QueryVolumeInformation(
  98.          goto out;
  99.      }
  100.  
  101. -    if (entry->status == STATUS_BUFFER_TOO_SMALL) {
  102. -        RxContext->InformationToReturn = entry->buf_len;
  103. -        status = STATUS_BUFFER_TOO_SMALL;
  104. -    } else if (entry->status == STATUS_SUCCESS) {
  105. +    if (entry->status == STATUS_BUFFER_OVERFLOW) {
  106. +        /*
  107. +         * Supplied buffer was too small, so we copied only part of
  108. +         * the data into the buffer
  109. +         */
  110. +        status = STATUS_BUFFER_OVERFLOW;
  111. +    }
  112. +    else if (entry->status == STATUS_SUCCESS) {
  113.  #ifdef ENABLE_TIMINGS
  114.          InterlockedIncrement(&volume.sops);
  115.          InterlockedAdd64(&volume.size, entry->u.Volume.buf_len);
  116. --
  117. 2.45.1
  118.  
  119. From d4de60c0ec48238977a8491c12b9cf64daf9b66a Mon Sep 17 00:00:00 2001
  120. From: Roland Mainz <roland.mainz@nrubsig.org>
  121. Date: Fri, 18 Jul 2025 13:58:16 +0200
  122. Subject: [PATCH 2/2] daemon: Increase size limit for EAs to 8192
  123.  
  124. Increase size limit for EAs from 2048 to 8192.
  125.  
  126. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  127. ---
  128. daemon/ea.c          | 8 ++++++++
  129.  daemon/nfs41_const.h | 2 +-
  130.  2 files changed, 9 insertions(+), 1 deletion(-)
  131.  
  132. diff --git a/daemon/ea.c b/daemon/ea.c
  133. index b9e68b7..a1fb42f 100644
  134. --- a/daemon/ea.c
  135. +++ b/daemon/ea.c
  136. @@ -32,6 +32,14 @@
  137.  #include "daemon_debug.h"
  138.  #include "nfs_ea.h"
  139.  
  140. +/*
  141. + * Compile safeguard to see whether |NFS4_EASIZE+header| will still fit into
  142. + * |UPCALL_BUF_SIZE|
  143. + */
  144. +#if (NFS4_EASIZE+1024) > UPCALL_BUF_SIZE
  145. +#error NFS4_EASIZE does not fit into UPCALL_BUF_SIZE
  146. +#endif
  147. +
  148.  /*
  149.   * |WIN_NFS4_EA_NAME_PREFIX| - Prefix for Windows EA in NFSv4
  150.   * XATTR (extended attributes) namespace
  151. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  152. index 524dd30..9ce6692 100644
  153. --- a/daemon/nfs41_const.h
  154. +++ b/daemon/nfs41_const.h
  155. @@ -42,7 +42,7 @@
  156.  #define NFS4_OPAQUE_LIMIT_ATTR  (8192)
  157.  #define NFS4_SESSIONID_SIZE     16
  158.  #define NFS4_STATEID_OTHER      12
  159. -#define NFS4_EASIZE             2048
  160. +#define NFS4_EASIZE             8192
  161.  #define NFS4_EANAME_SIZE        128
  162.  
  163.  #define NFSD_THREAD_STACK_SIZE (4*1024*1024)
  164. --
  165. 2.45.1

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at