pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for |nfs41_SetZeroData()| access checks, docs updates+misc, 2025-02-18
Posted by Anonymous on Tue 18th Feb 2025 17:09
raw | new post

  1. From b913f165fb8aacb7298e26f93d8b75e4f62811dd Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 18 Feb 2025 10:10:38 +0100
  4. Subject: [PATCH 1/3] cygwin: Add "Windows Server 2022" to the list of
  5.  supported platforms
  6.  
  7. Add "Windows Server 2022" to the list of supported platforms
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. cygwin/README.bintarball.txt | 4 ++--
  12.  1 file changed, 2 insertions(+), 2 deletions(-)
  13.  
  14. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  15. index 1958023..c5bc86e 100644
  16. --- a/cygwin/README.bintarball.txt
  17. +++ b/cygwin/README.bintarball.txt
  18. @@ -10,7 +10,7 @@
  19.  #
  20.  # 1. What is this ?
  21.  #
  22. -NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019
  23. +NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019+2022
  24.  
  25.  
  26.  #
  27. @@ -131,7 +131,7 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019
  28.  #
  29.  # 3. Requirements:
  30.  #
  31. -- Windows 10 (32bit or 64bit), Windows 11 or Windows Server 2019
  32. +- Windows 10 (32bit or 64bit), Windows 11 or Windows Server 2019+2022
  33.  - Cygwin:
  34.      - Cygwin versions:
  35.          - 64bit: >= 3.5.7 (or 3.6.x-devel)
  36. --
  37. 2.45.1
  38.  
  39. From 39577584e8c2f99390f19eb7f87e93562a9fae3f Mon Sep 17 00:00:00 2001
  40. From: Roland Mainz <roland.mainz@nrubsig.org>
  41. Date: Tue, 18 Feb 2025 10:58:49 +0100
  42. Subject: [PATCH 2/3] cygwin: README.bintarball.txt: Rewording+spelling fixes
  43.  
  44. README.bintarball.txt: Rewording+spelling fixes
  45.  
  46. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  47. ---
  48. cygwin/README.bintarball.txt | 44 ++++++++++++++++++++----------------
  49.  1 file changed, 24 insertions(+), 20 deletions(-)
  50.  
  51. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  52. index c5bc86e..76ec183 100644
  53. --- a/cygwin/README.bintarball.txt
  54. +++ b/cygwin/README.bintarball.txt
  55. @@ -25,8 +25,9 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019+2022
  56.      client can use different ports per mount)
  57.  
  58.  - Support for nfs://-URLs
  59. -    * Why ? nfs://-URLs are crossplatform, portable and Character-Encoding
  60. -      independent descriptions of NFSv4 server resources (exports).
  61. +    * Why ? nfs://-URLs are cross-platform, portable and
  62. +      Character-Encoding independent descriptions of NFSv4 server
  63. +      resources (exports).
  64.      - including custom ports and raw IPv6 addresses
  65.      - nfs://-URL conversion utility (/usr/bin/nfsurlconv) to convert
  66.          URLs, including non-ASCII/Unicode characters in mount path
  67. @@ -68,23 +69,26 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019+2022
  68.      - Windows Explorer ACL dialog
  69.  
  70.  - Sparse file support
  71. -    - Requires Cygwin 3.6 and a MFSv4.2 server
  72. -    - Full sparse file support, including creation, punching holes
  73. -      (via NFSv4.2 DEALLOCATE), enumeration of hole&data ranges etc.
  74. +    - Requires NFSv4.2 server which supports the NFSv4.2
  75. +      operations "ALLOCATE", "DEALLOCATE", "SEEK", and the
  76. +      |FATTR4_WORD1_SPACE_USED| attribute.
  77. +    - Full Win32 sparse file API support, including creation,
  78. +      punching holes, enumeration of hole&data ranges etc.
  79.      - Supports Win32 APIs |FSCTL_QUERY_ALLOCATED_RANGES|,
  80. -      |FSCTL_SET_SPARSE|, |FSCTL_SET_ZERO_DATA|; NFSv4.1
  81. -      |FATTR4_WORD1_SPACE_USED| is mapped to Win32
  82. -      |FILE_STANDARD_INFORMATION.AllocationSize| and
  83. -      |NfsV3Attributes.used| EA for sparse file support.
  84. -    - Cygwin >= 3.6 support POSIX-1.2024 |lseek(...,SEEK_HOLE,...)|
  85. -      and |lseek(...,SEEK_DATA,...)|, coreutils /usr/bin/fallocate
  86. -      and $ /usr/bin/cp --sparse=auto src dest #
  87. +      |FSCTL_SET_SPARSE|, |FSCTL_SET_ZERO_DATA|; and
  88. +      |NfsV3Attributes.used| EA
  89. +    - Cygwin sparse file support requires >= Cygwin 3.6 to support
  90. +      POSIX-1.2024 |lseek(...,SEEK_HOLE/SEEK_DATA,...)|, which is
  91. +      needed for coreutils /usr/bin/fallocate and
  92. +      $ /usr/bin/cp --sparse=auto src dest #
  93.      - /cygdrive/c/Windows/system32/fsutil sparse queryrange myfile.dat
  94.        can be used to enumerate ranges where data are allocated
  95.        (BUG: Win10+Win11 fsutil only support 64 data ranges, the
  96.        filesystem itself supports an unlimited number of data ranges)
  97. -    - /cygdrive/c/Windows/system32/xcopy /sparse (on Win11) can be
  98. -      used to copy sparse files
  99. +    - /cygdrive/c/Windows/system32/xcopy /sparse can be
  100. +      used to copy sparse files.
  101. +      Requires on Win11 >= 22H2 because it relies on |CopyFile2()|
  102. +      flag |COPY_FILE_ENABLE_SPARSE_COPY|.
  103.  
  104.  - Symlink reparse and translation support
  105.      - Translates Win32/NT symlink syntax (e.g.
  106. @@ -304,12 +308,12 @@ $ (set -o xtrace ; cd / && tar -tf ~/download/${bintarball.base_filename}.tar.bz
  107.  
  108.  # Option a)
  109.  # * Start NFSv4 client daemon as Windows service (requires
  110. -# "Adminstrator" account):
  111. +# "Administrator" account):
  112.  
  113.  $ sc start ms-nfs41-client-service
  114.  
  115.  # * Notes:
  116. -# - requires "Adminstrator" account, and one nfsd client daemon is
  117. +# - requires "Administrator" account, and one nfsd client daemon is
  118.  #   used for all users on a machine.
  119.  # - The "ms-nfs41-client-service" service is installed by default as
  120.  #   "disabled" and therefore always requires a "manual" start (e.g.
  121. @@ -472,7 +476,7 @@ $ mount -t drvfs '\0.49.202.230@2049\nfs4\bigdisk' /mnt/bigdisk
  122.  
  123.  - Cygwin/MSYS2 symlinks are supported, but might require
  124.    $ fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1 #.
  125. -  This includes symlinks to UNC paths, e.g. as Admin
  126. +  This includes symlinks to UNC paths, e.g. as Administrator
  127.    $ cmd /c 'mklink /d c:\home\rmainz \\derfwpc5131_ipv6@2049\nfs4\export\home2\rmainz' #
  128.    and then $ cd /cygdrive/c/home/rmainz/ # should work
  129.  
  130. @@ -482,7 +486,7 @@ $ mount -t drvfs '\0.49.202.230@2049\nfs4\bigdisk' /mnt/bigdisk
  131.  - bad performance due to Windows Defender AntiVirus:
  132.    Option 1:
  133.    # disable Windows defender realtime monitoring
  134. -  # (requires Admin shell)
  135. +  # (requires Administrator shell)
  136.    powershell -Command 'Set-MpPreference -DisableRealtimeMonitoring 1'
  137.    Option 2:
  138.    Add "nfsd.exe", "nfsd_debug.exe", "ksh93.exe", "bash.exe",
  139. @@ -563,7 +567,7 @@ $ mount -t drvfs '\0.49.202.230@2049\nfs4\bigdisk' /mnt/bigdisk
  140.    Working theory is that this is related to FCB caching, see
  141.    |FCB_STATE_FILESIZECACHEING_ENABLED|, as the nfs41_driver.sys
  142.    kernel module does not see the |stat()| syscalls. But $ tail -f ... #
  143. -  always works for a momemnt if something else opens the same file.
  144. +  always works for a moment if something else opens the same file.
  145.  
  146.  - Unmounting and then mounting the same filesystem causes issues
  147.    as the name cache in nfsd*.exe is not flushed on umount, including
  148. @@ -669,7 +673,7 @@ $ mount -t drvfs '\0.49.202.230@2049\nfs4\bigdisk' /mnt/bigdisk
  149.  - The "msnfs41client" script has the option "watch_kernel_debuglog"
  150.    to get the debug output of the kernel module.
  151.  
  152. -  Run as Admin: $ /sbin/msnfs41client watch_kernel_debuglog #
  153. +  Run as Administrator: $ /sbin/msnfs41client watch_kernel_debuglog #
  154.  
  155.    Currently requires DebugView
  156.    (https://learn.microsoft.com/en-gb/sysinternals/downloads/debugview)
  157. --
  158. 2.45.1
  159.  
  160. From 9c23d89b9c7f7b334fcc4e652aeaadfe19c8c5ba Mon Sep 17 00:00:00 2001
  161. From: Roland Mainz <roland.mainz@nrubsig.org>
  162. Date: Tue, 18 Feb 2025 11:27:19 +0100
  163. Subject: [PATCH 3/3] sys: Add access checks to |nfs41_SetZeroData()|
  164.  
  165. Add access checks to |nfs41_SetZeroData()| (e.g. for read-only
  166. mounts).
  167.  
  168. Reported-by: Lionel Cons <lionelcons1972@gmail.com>
  169. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  170. ---
  171. sys/nfs41sys_fsctl.c | 35 +++++++++++++++++++++++++++++++++++
  172.  1 file changed, 35 insertions(+)
  173.  
  174. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  175. index acacf7e..3157b54 100644
  176. --- a/sys/nfs41sys_fsctl.c
  177. +++ b/sys/nfs41sys_fsctl.c
  178. @@ -319,6 +319,14 @@ NTSTATUS nfs41_SetSparse(
  179.  
  180.      DbgEn();
  181.  
  182. +    /*
  183. +     * We do not do any access checks here because ms-nfs41-client
  184. +     * files always have the |FILE_ATTRIBUTE_SPARSE_FILE| set.
  185. +     * This function is basically only a dummy which returns
  186. +     * |STATUS_SUCCESS| (if the correct are provided) to conform
  187. +     * sto the Win32 sparse file API.
  188. +     */
  189. +
  190.      /*
  191.       * Special case: No input buffer, so we treat this as if we got
  192.       * |set_parse_buffer->SetSparse == TRUE|
  193. @@ -368,6 +376,29 @@ out:
  194.      return status;
  195.  }
  196.  
  197. +static
  198. +NTSTATUS check_nfs41_setzerodata_args(
  199. +    PRX_CONTEXT RxContext)
  200. +{
  201. +    NTSTATUS status = STATUS_SUCCESS;
  202. +    __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
  203. +    __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
  204. +        NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
  205. +
  206. +    /* access checks */
  207. +    if (VNetRootContext->read_only) {
  208. +        status = STATUS_MEDIA_WRITE_PROTECTED;
  209. +        goto out;
  210. +    }
  211. +    if (!(SrvOpen->DesiredAccess &
  212. +        (FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES))) {
  213. +        status = STATUS_ACCESS_DENIED;
  214. +        goto out;
  215. +    }
  216. +out:
  217. +    return status;
  218. +}
  219. +
  220.  static
  221.  NTSTATUS nfs41_SetZeroData(
  222.      IN OUT PRX_CONTEXT RxContext)
  223. @@ -389,6 +420,10 @@ NTSTATUS nfs41_SetZeroData(
  224.  
  225.      RxContext->IoStatusBlock.Information = 0;
  226.  
  227. +    status = check_nfs41_setzerodata_args(RxContext);
  228. +    if (status)
  229. +        goto out;
  230. +
  231.      if (FsCtl->InputBufferLength <
  232.          sizeof(FILE_ZERO_DATA_INFORMATION)) {
  233.          DbgP("nfs41_SetZeroData: "
  234. --
  235. 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