pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for install refactoring to support any platform, ARM64 platform fixes, kernel2userland buffer fixes, cleanup+misc, 2025-09-24
Posted by Anonymous on Wed 24th Sep 2025 20:43
raw | new post

  1. From 308081b6da4ce62385ae678d2250f4a0ee4ef3f2 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 23 Sep 2025 14:28:33 +0200
  4. Subject: [PATCH 1/6] cygwin: Refactor cygwin/Makefile*+msnfs41client.bash for
  5.  multiple architectures
  6.  
  7. Refactor cygwin/Makefile*+msnfs41client.bash for multiple architectures.
  8.  
  9. Goals:
  10. - Support any platform { ARM64, x86-32bit, x86-64bit } from
  11.   { cygwin x86/32bit, cygwin/x86-64 64bit on x86-64, cygwin/x86-64 64bit
  12.   on ARM64  }
  13. - Move hardlink generation to $ /sbin/msnfs41client install # time
  14. - Support 32bit-only, 64bit-only and 32bit+64bit binary tarball generation
  15.  
  16. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  17. ---
  18. cygwin/Makefile                 |  55 +++++-----
  19.  cygwin/Makefile.install         | 177 +++++++++++++++-----------------
  20.  cygwin/devel/msnfs41client.bash |  98 ++++++++++++++++--
  21.  3 files changed, 203 insertions(+), 127 deletions(-)
  22.  
  23. diff --git a/cygwin/Makefile b/cygwin/Makefile
  24. index de3ad27..febbbb2 100644
  25. --- a/cygwin/Makefile
  26. +++ b/cygwin/Makefile
  27. @@ -13,10 +13,13 @@ PROJECT_BASEDIR_DIR := $(shell dirname $(realpath $(CYGWIN_MAKEFILE_DIR)/))
  28.  
  29.  DESTDIR:=$(PROJECT_BASEDIR_DIR)/destdir
  30.  
  31. -VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/
  32. -VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
  33. -#VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Release/
  34. -#VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Release/
  35. +VS_BUILD_DIR_I686:=$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/
  36. +VS_BUILD_DIR_X64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
  37. +VS_BUILD_DIR_ARM64:=$(PROJECT_BASEDIR_DIR)/build.vc19/ARM64/Debug/
  38. +#VS_BUILD_DIR_I686:=$(PROJECT_BASEDIR_DIR)/build.vc19/Release/
  39. +#VS_BUILD_DIR_X64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Release/
  40. +#VS_BUILD_DIR_ARM64:=$(PROJECT_BASEDIR_DIR)/build.vc19/ARM64/Release/
  41. +
  42.  
  43.  # trigger "build_testutils" target when these binaries are needed
  44.  $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
  45. @@ -136,36 +139,42 @@ installdest_util: \
  46.         $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash
  47.  
  48.  installdest32: \
  49. -       $(VS_BUILD_DIR32)/nfsd.exe \
  50. -       $(VS_BUILD_DIR32)/nfs_mount.exe \
  51. -       $(VS_BUILD_DIR32)/nfs_install.exe \
  52. -       $(VS_BUILD_DIR32)/nfs41_driver.sys \
  53. -       $(VS_BUILD_DIR32)/libtirpc.dll \
  54. -       $(VS_BUILD_DIR32)/nfs41_np.dll \
  55. +       $(VS_BUILD_DIR_I686)/nfsd.exe \
  56. +       $(VS_BUILD_DIR_I686)/nfs_mount.exe \
  57. +       $(VS_BUILD_DIR_I686)/nfs_install.exe \
  58. +       $(VS_BUILD_DIR_I686)/nfs41_driver.sys \
  59. +       $(VS_BUILD_DIR_I686)/libtirpc.dll \
  60. +       $(VS_BUILD_DIR_I686)/nfs41_np.dll \
  61.         # installdest 32bit Windows
  62.         make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
  63.                 installdest \
  64. -               VS_BUILD_DIR="$(VS_BUILD_DIR32)" \
  65. -               VS_BUILD_DIR32="$(VS_BUILD_DIR32)" \
  66. -               VS_BUILD_DIR64="$(VS_BUILD_DIR64)" \
  67. +               VS_BUILD_DIR_I686="$(VS_BUILD_DIR_I686)" \
  68. +               VS_BUILD_DIR_X64="" \
  69. +               VS_BUILD_DIR_ARM64="" \
  70.                 CYGWIN_BASEPATH=/cygdrive/c/cygwin/
  71.  
  72.  # installdest64: 32bit nfs41_np.dll is required to support 32bit
  73.  # apps on 64bit Windows
  74.  installdest64: \
  75. -       $(VS_BUILD_DIR64)/nfsd.exe \
  76. -       $(VS_BUILD_DIR64)/nfs_mount.exe \
  77. -       $(VS_BUILD_DIR64)/nfs_install.exe \
  78. -       $(VS_BUILD_DIR64)/nfs41_driver.sys \
  79. -       $(VS_BUILD_DIR64)/libtirpc.dll \
  80. -       $(VS_BUILD_DIR32)/nfs41_np.dll \
  81. -       $(VS_BUILD_DIR64)/nfs41_np.dll \
  82. +       $(VS_BUILD_DIR_X64)/nfsd.exe \
  83. +       $(VS_BUILD_DIR_X64)/nfs_mount.exe \
  84. +       $(VS_BUILD_DIR_X64)/nfs_install.exe \
  85. +       $(VS_BUILD_DIR_X64)/nfs41_driver.sys \
  86. +       $(VS_BUILD_DIR_X64)/libtirpc.dll \
  87. +       $(VS_BUILD_DIR_X64)/nfs41_np.dll \
  88. +       $(VS_BUILD_DIR_ARM64)/nfsd.exe \
  89. +       $(VS_BUILD_DIR_ARM64)/nfs_mount.exe \
  90. +       $(VS_BUILD_DIR_ARM64)/nfs_install.exe \
  91. +       $(VS_BUILD_DIR_ARM64)/nfs41_driver.sys \
  92. +       $(VS_BUILD_DIR_ARM64)/libtirpc.dll \
  93. +       $(VS_BUILD_DIR_ARM64)/nfs41_np.dll \
  94. +       $(VS_BUILD_DIR_I686)/nfs41_np.dll \
  95.         # installdest 64bit Windows
  96.         make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
  97.                 installdest \
  98. -               VS_BUILD_DIR="$(VS_BUILD_DIR64)" \
  99. -               VS_BUILD_DIR32="$(VS_BUILD_DIR32)" \
  100. -               VS_BUILD_DIR64="$(VS_BUILD_DIR64)" \
  101. +               VS_BUILD_DIR_I686="$(VS_BUILD_DIR_I686)" \
  102. +               VS_BUILD_DIR_X64="$(VS_BUILD_DIR_X64)" \
  103. +               VS_BUILD_DIR_ARM64="$(VS_BUILD_DIR_ARM64)" \
  104.                 CYGWIN_BASEPATH=/cygdrive/c/cygwin64/
  105.  
  106.  # installdest: we need a .WAIT here becase Makefile.install uses git commands
  107. diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
  108. index 337014e..a6029a6 100644
  109. --- a/cygwin/Makefile.install
  110. +++ b/cygwin/Makefile.install
  111. @@ -13,13 +13,6 @@ PROJECT_BASEDIR_DIR := $(shell dirname $(realpath $(CYGWIN_MAKEFILE_DIR)/))
  112.  
  113.  DESTDIR := $(PROJECT_BASEDIR_DIR)/destdir
  114.  
  115. -# link *.exe
  116. -# We have to use hardlinks here, because cygwin defaults to use <JUNCTION>s,
  117. -# which neither cmd.exe nor powershell can follow. <SYMLINK>s are not an option,
  118. -# because it woulld required the "SeCreateSymbolicLinkPrivilege", which by default
  119. -# not even the Adminstrator has
  120. -LINKEXE = ln -f
  121. -
  122.  # install in DESTDIR
  123.  installdest:
  124.         #
  125. @@ -36,6 +29,9 @@ installdest:
  126.         # /usr/lib is a bind mount to C:/cygwin64/lib, so copy library data to /$(CYGWIN_BASEPATH)/lib
  127.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib
  128.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client
  129. +       mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686
  130. +       if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64 ; fi
  131. +       if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64 ; fi
  132.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/etc
  133.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/src/msnfs41client
  134.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/man/man1
  135. @@ -44,48 +40,71 @@ installdest:
  136.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc
  137.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles
  138.         mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests
  139. -       cp $(VS_BUILD_DIR)/nfsd.exe             $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfsd_debug.exe
  140. -       cp $(VS_BUILD_DIR)/nfsd.pdb             $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfsd_debug.pdb
  141. -       cp $(VS_BUILD_DIR)/nfs_mount.*  $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
  142. -       # we need a hardlink for nfs_umount.exe, softlinks do not work
  143. -       ln -f $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.exe  $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_umount.exe
  144. +       #
  145. +       # copy x86 binaries
  146. +       #
  147. +       if [[ -f "$(VS_BUILD_DIR_I686)/nfs41_driver.sys" ]] ; then \
  148. +               # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
  149. +               chattr -V -c $(VS_BUILD_DIR_I686)/nfs41_driver.* ; \
  150. +               cp $(VS_BUILD_DIR_I686)/nfs41_driver.*  $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
  151. +               cp $(VS_BUILD_DIR_I686)/nfsd.*          $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
  152. +               cp $(VS_BUILD_DIR_I686)/libtirpc.*      $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
  153. +               cp $(VS_BUILD_DIR_I686)/nfs_install.*   $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
  154. +       fi
  155. +       cp $(VS_BUILD_DIR_I686)/nfs_mount.*     $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/.
  156.         # install 32bit nfs_mount.exe on 64bit Windows to assist with debugging 32bit issues
  157.         # we use the "Release" version on 64bit to avoid issues with missing debug libraries
  158.         # on 32bit we just create a hardlink from nfs_mount.exe to nfs_mount.i686.exe
  159. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  160. -               cp $(VS_BUILD_DIR32)/../Release/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe ; \
  161. -       else \
  162. -               ln -f $(VS_BUILD_DIR32)/../Debug/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe ; \
  163. +       cp $(VS_BUILD_DIR_I686)/../Release/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs_mount.release.i686.exe
  164. +       cp $(VS_BUILD_DIR_I686)/../Release/nfs41_np.dll $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.release.dll
  165. +       cp $(VS_BUILD_DIR_I686)/nfs41_np.*      $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
  166. +       #
  167. +       # copy x64 binaries
  168. +       #
  169. +       if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
  170. +               if [[ -f "$(VS_BUILD_DIR_X64)/nfs41_driver.sys" ]] ; then \
  171. +                       # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
  172. +                       chattr -V -c $(VS_BUILD_DIR_X64)/nfs41_driver.* ; \
  173. +                       cp $(VS_BUILD_DIR_X64)/nfs41_driver.*   $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  174. +                       cp $(VS_BUILD_DIR_X64)/nfsd.*           $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  175. +                       cp $(VS_BUILD_DIR_X64)/libtirpc.*       $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  176. +                       cp $(VS_BUILD_DIR_X64)/nfs_install.*    $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  177. +               fi ; \
  178. +               cp $(VS_BUILD_DIR_X64)/nfs_mount.*      $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  179. +               cp $(VS_BUILD_DIR_X64)/nfs41_np.*       $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
  180.         fi
  181. -       ln -f $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_umount.i686.exe
  182. -       cp $(VS_BUILD_DIR)/nfsd.*               $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
  183. -       cp $(VS_BUILD_DIR)/nfs_install.*        $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
  184. -       cp $(VS_BUILD_DIR)/libtirpc.*   $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
  185. -       cp $(VS_BUILD_DIR)/nfs41_np.*   $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
  186. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  187. -               mkdir -p -- $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686 ; \
  188. -               cp $(VS_BUILD_DIR32)/../Release/nfs41_np.dll $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.dll ; \
  189. -               cp $(VS_BUILD_DIR32)/../Release/nfs41_np.exp $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.exp ; \
  190. -               cp $(VS_BUILD_DIR32)/../Release/nfs41_np.lib $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.lib ; \
  191. -               cp $(VS_BUILD_DIR32)/../Release/nfs41_np.pdb $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.pdb ; \
  192. +       #
  193. +       # copy ARM64 binaries
  194. +       #
  195. +       if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
  196. +               if [[ -f "$(VS_BUILD_DIR_ARM64)/nfs41_driver.sys" ]] ; then \
  197. +                       # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
  198. +                       chattr -V -c $(VS_BUILD_DIR_ARM64)/nfs41_driver.* ; \
  199. +                       cp $(VS_BUILD_DIR_ARM64)/nfs41_driver.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  200. +                       cp $(VS_BUILD_DIR_ARM64)/nfsd.*         $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  201. +                       cp $(VS_BUILD_DIR_ARM64)/libtirpc.*     $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  202. +                       cp $(VS_BUILD_DIR_ARM64)/nfs_install.*  $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  203. +               fi ; \
  204. +               cp $(VS_BUILD_DIR_ARM64)/nfs_mount.*    $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  205. +               cp $(VS_BUILD_DIR_ARM64)/nfs41_np.*     $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
  206.         fi
  207. -       # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files
  208. -       chattr -V -c $(VS_BUILD_DIR)/nfs41_driver.*
  209. -       cp $(VS_BUILD_DIR)/nfs41_driver.*       $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
  210. -       # Copy kernel driver INF file
  211. -       cp $(PROJECT_BASEDIR_DIR)/nfs41rdr.inf  $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
  212. -       # generate signature catalog
  213. +       # Copy kernel driver INF file and generate signature catalog
  214.         # (inf2cat.exe cannot handle case-sensitive filesystems like NFS for temporary files, so we reset TMP&co)
  215. -       ( \
  216. -               inf2catbin="$$(find '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin' -iname inf2cat.exe | head -n 1)" && \
  217. -               cd "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/" && \
  218. -               if [[ "$$(/usr/lib/csih/getVolInfo . | awk '/FILE_CASE_SENSITIVE_SEARCH/ { print $$3 }')" == "TRUE" ]] ; then \
  219. -                       printf "# case-sensitive filesystem, resetting TMP TMPDIR TEMP to /tmp\n" ; \
  220. -                       export TMP=/tmp TMPDIR=/tmp TEMP=/tmp ; \
  221. -               fi && \
  222. -               set -o xtrace ; \
  223. -               "$$inf2catbin" /driver:. /os:10_X86,10_X64,10_VB_ARM64 \
  224. -       )
  225. +       for infdir in "i686" "x64" "ARM64" ; do \
  226. +               [[ -f "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/nfs41_driver.sys" ]] || continue ; \
  227. +               ( \
  228. +                       cp "$(PROJECT_BASEDIR_DIR)/nfs41rdr.inf" "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/." && \
  229. +                       inf2catbin="$$(find '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin' -iname inf2cat.exe | head -n 1)" && \
  230. +                       cd "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/." && \
  231. +                       if [[ "$$(/usr/lib/csih/getVolInfo . | awk '/FILE_CASE_SENSITIVE_SEARCH/ { print $$3 }')" == "TRUE" ]] ; then \
  232. +                               printf "# case-sensitive filesystem, resetting TMP TMPDIR TEMP to /tmp\n" ; \
  233. +                               export TMP=/tmp TMPDIR=/tmp TEMP=/tmp ; \
  234. +                       fi && \
  235. +                       set -o xtrace ; \
  236. +                       "$$inf2catbin" /driver:. /os:10_X86,10_X64,10_VB_ARM64 \
  237. +               ) ; \
  238. +       done
  239. +       # Platform-independent files
  240.         cp $(PROJECT_BASEDIR_DIR)/etc_netconfig $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
  241.         cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf           $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
  242.         cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash      $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/msnfs41client
  243. @@ -120,64 +139,21 @@ installdest:
  244.         cp "$(PROJECT_BASEDIR_DIR)/tests/manual_testing.txt" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/manual_testing.txt
  245.         cp "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winfsinfo.x86_64.exe
  246.         cp "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winfsinfo.i686.exe
  247. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  248. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winfsinfo.x86_64.exe winfsinfo.exe) \
  249. -       else \
  250. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winfsinfo.i686.exe winfsinfo.exe) \
  251. -       fi
  252.         cp "$(PROJECT_BASEDIR_DIR)/tests/winclonefile/winclonefile.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winclonefile.x86_64.exe
  253.         cp "$(PROJECT_BASEDIR_DIR)/tests/winclonefile/winclonefile.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winclonefile.i686.exe
  254. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  255. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winclonefile.x86_64.exe winclonefile.exe) \
  256. -       else \
  257. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winclonefile.i686.exe winclonefile.exe) \
  258. -       fi
  259.         cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winoffloadcopyfile.x86_64.exe
  260.         cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winoffloadcopyfile.i686.exe
  261. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  262. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winoffloadcopyfile.x86_64.exe winoffloadcopyfile.exe) \
  263. -       else \
  264. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winoffloadcopyfile.i686.exe winoffloadcopyfile.exe) \
  265. -       fi
  266.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/winrunassystem.x86_64.exe
  267.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/winrunassystem.i686.exe
  268. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  269. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) winrunassystem.x86_64.exe winrunassystem.exe) \
  270. -       else \
  271. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) winrunassystem.i686.exe winrunassystem.exe) \
  272. -       fi
  273.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/nfs_globalmount.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_globalmount.x86_64.exe
  274.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/nfs_globalmount.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_globalmount.i686.exe
  275. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  276. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) nfs_globalmount.x86_64.exe nfs_globalmount.exe) \
  277. -       else \
  278. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) nfs_globalmount.i686.exe nfs_globalmount.exe) \
  279. -       fi
  280.         cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.x86_64.exe
  281. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  282. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) lssparse.x86_64.exe lssparse.exe) \
  283. -       fi
  284.         cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.x86_64.exe
  285.         cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.i686.exe
  286. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  287. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winsg.x86_64.exe winsg.exe) \
  288. -       else \
  289. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winsg.i686.exe winsg.exe) \
  290. -       fi
  291.         cp "$(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/nfs_ea.x86_64.exe
  292.         cp "$(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/nfs_ea.i686.exe
  293. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  294. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) nfs_ea.x86_64.exe nfs_ea.exe) \
  295. -       else \
  296. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) nfs_ea.i686.exe nfs_ea.exe) \
  297. -       fi
  298.         cp "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests/qsortonmmapedfile1.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1.x86_64.exe
  299.         cp "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests/qsortonmmapedfile1.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1.i686.exe
  300. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  301. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/ && $(LINKEXE) qsortonmmapedfile1.x86_64.exe qsortonmmapedfile1.exe) \
  302. -       else \
  303. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/ && $(LINKEXE) qsortonmmapedfile1.i686.exe qsortonmmapedfile1.exe) \
  304. -       fi
  305.         cp $(PROJECT_BASEDIR_DIR)/tests/filemmaptests/testqsortonmmapedfile1.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/testqsortonmmapedfile1.ksh93
  306.         cp $(PROJECT_BASEDIR_DIR)/tests/nfsbuildtest/nfsbuildtest.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/nfsbuildtest.ksh93
  307.         cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparsefile1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparsefile1.ksh
  308. @@ -195,21 +171,32 @@ installdest:
  309.         typeset msbuildpath="$$(which MSBuild.exe)" ; \
  310.         typeset vsbasepath="$${msbuildpath%*/Community/*}" ; \
  311.         test -d "$${vsbasepath}" || { printf "vsbasepath not found\n" 1>&2 ; exit 1 ; }; \
  312. -       if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  313. +       cp \
  314. +               "$$(find "$${vsbasepath}/Community" -ipath '*/x86/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
  315. +               "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/." ; \
  316. +       cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x86/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/." ; \
  317. +       if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
  318.                 cp \
  319.                         "$$(find "$${vsbasepath}/Community" -ipath '*/x64/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
  320. -                       $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
  321. -               cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x64/ucrt/ucrtbased.dll' $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
  322. -       else \
  323. +                       "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/." ; \
  324. +               cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x64/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/." ; \
  325. +       fi ; \
  326. +       if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
  327.                 cp \
  328. -                       "$$(find "$${vsbasepath}/Community" -ipath '*/x86/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
  329. -                       $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
  330. -               cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x86/ucrt/ucrtbased.dll' $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
  331. +                       "$$(find "$${vsbasepath}/Community" -ipath '*/arm64/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
  332. +                       "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/." ; \
  333. +               cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/arm64/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/." ; \
  334.         fi
  335.         @ printf "# Set file flags\n"
  336.         (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && chmod a+rx *.exe)
  337. -       (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && chmod a+rx *.exe *.dll)
  338. -       (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ && chmod a+rx *.dll)
  339. +       (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && chmod a+rx *.exe)
  340. +       (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686 && chmod a+rx *.exe *.dll)
  341. +       if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
  342. +               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64 && chmod a+rx *.exe *.dll) ; \
  343. +       fi
  344. +       if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
  345. +               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64 && chmod a+rx *.exe *.dll) ; \
  346. +       fi
  347.         @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/"
  348.         @printf '\n'
  349.         @printf "\n#\n# Now use\n# $$ cd '%s' && ./msnfs41client install #\n# to install the kernel driver as Admin\n#\n" \
  350. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  351. index 0dfc94a..975e089 100755
  352. --- a/cygwin/devel/msnfs41client.bash
  353. +++ b/cygwin/devel/msnfs41client.bash
  354. @@ -184,10 +184,96 @@ function nfsclient_install
  355.         # make sure all binaries are executable, Windows cmd does
  356.         # not care, but Cygwin&bash do.
  357.         # If *.ddl are not executable nfs*.exe fail with 0xc0000022
  358. +       typeset uname_m="$(uname -m)"
  359. +       typeset uname_s="$(uname -s)"
  360. +       typeset kernel_platform
  361. +       case "${uname_m}" in
  362. +               'x86_64')
  363. +                       if [[ "${uname_s}" == *-ARM64 ]] ; then
  364. +                               kernel_platform='ARM64'
  365. +                       else
  366. +                               kernel_platform='x64'
  367. +                       fi
  368. +                       ;;
  369. +               'i686')
  370. +                       kernel_platform='i686'
  371. +                       ;;
  372. +               *)
  373. +                       printf $"%s: Unsupported platform %q\n" "$0" "${uname_m}"
  374. +                       return 1
  375. +                       ;;
  376. +       esac
  377. +
  378. +       platform_dir="$PWD/${kernel_platform}"
  379. +
  380. +       #
  381. +       # We have to use hardlinks here, because cygwin defaults to use <JUNCTION>s,
  382. +       # which neither cmd.exe nor powershell can follow. <SYMLINK>s are not an option,
  383. +       # because it woulld required the "SeCreateSymbolicLinkPrivilege", which by default
  384. +       # not even the Adminstrator has
  385. +       #
  386. +
  387. +       ln -f "${platform_dir}"/nfs41_driver.*          .
  388. +       ln -f "${platform_dir}"/nfsd.*                  .
  389. +       ln -f "${platform_dir}"/nfs_install.*           .
  390. +       ln -f "${platform_dir}"/nfs_mount.*             .
  391. +       ln -f "${platform_dir}"/libtirpc.*              .
  392. +       ln -f "${platform_dir}"/nfs41_np.*              .
  393. +       ln -f "${platform_dir}"/nfs41rdr.inf            .
  394. +       ln -f "${platform_dir}/VCRUNTIME140D.dll"       .
  395. +       ln -f "${platform_dir}/ucrtbased.dll"           .
  396. +
  397. +       # add hardlinks in /sbin
  398. +       ln -f "nfsd".*                          "../../sbin/."
  399. +       ln -f "nfs_install".*                   "../../sbin/."
  400. +       ln -f "nfs_mount".*                     "../../sbin/."
  401. +       ln -f "libtirpc".*                      "../../sbin/."
  402. +       ln -f "VCRUNTIME140D.dll"               "../../sbin/."
  403. +       ln -f "ucrtbased.dll"                   "../../sbin/."
  404. +       ln -f "../../sbin/nfs_mount.exe"        "../../sbin/nfs_umount.exe"
  405. +       if [[ "${kernel_platform}" != 'i686' ]] ; then
  406. +               ln -f 'i686/nfs_mount.release.i686.exe' "../../sbin/nfs_mount.i686.exe"
  407. +       fi
  408. +
  409. +       typeset -a platformspecificexe=(
  410. +               'bin/winfsinfo'
  411. +               'bin/winclonefile'
  412. +               'bin/winoffloadcopyfile'
  413. +               'bin/winsg'
  414. +               'bin/nfs_ea'
  415. +               'sbin/winrunassystem'
  416. +               'sbin/nfs_globalmount'
  417. +               'usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1'
  418. +       )
  419. +
  420. +       if [[ "${kernel_platform}" != 'i686' ]] ; then
  421. +               # lssparse needs Cygwin >= 3.5 (|lseek(..., SEEK_HOLE, ...)| support), which is not available
  422. +               # for Windows 32bit
  423. +               platformspecificexe+=( 'bin/lssparse' )
  424. +       fi
  425. +
  426. +       for i in "${platformspecificexe[@]}"; do
  427. +               case "${kernel_platform}" in
  428. +                       'x64')
  429. +                               ln -f "../../${i}.x86_64.exe" "../../${i}.exe"
  430. +                               ;;
  431. +                       'ARM64')
  432. +                               if [[ -f "../../${i}.arm64.exe" ]] ; then
  433. +                                       ln -f "../../${i}.arm64.exe" "../../${i}.exe"
  434. +                               else
  435. +                                       ln -f "../../${i}.x86_64.exe" "../../${i}.exe"
  436. +                               fi
  437. +                               ;;
  438. +                       'i686')
  439. +                               ln -f "../../${i}.i686.exe" "../../${i}.exe"
  440. +                               ;;
  441. +               esac
  442. +       done
  443. +
  444.         chmod a+x *.dll
  445.         chmod a+x ../../sbin/nfs*.exe ../../sbin/libtirpc*.dll
  446.  
  447. -       # (re-)install driver
  448. +       # (re-)install driver and network provider DLL(s) (nfs41_np.dll)
  449.         nfsclient_adddriver
  450.  
  451.         mkdir -p /cygdrive/c/etc
  452. @@ -207,8 +293,6 @@ function nfsclient_install
  453.         od -t x4 <'/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled'
  454.  
  455.         # use the Win10 "SegmentHeap" (see https://www.blackhat.com/docs/us-16/materials/us-16-Yason-Windows-10-Segment-Heap-Internals.pdf)
  456. -       regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd_debug.exe'
  457. -       regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd_debug.exe/FrontEndHeapDebugOptions' 0x08
  458.         regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe'
  459.         regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe/FrontEndHeapDebugOptions' 0x08
  460.         regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
  461. @@ -232,7 +316,7 @@ function nfsclient_install
  462.                 win_domainname="$( strings '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' )"
  463.         fi
  464.         if [[ "${win_domainname}" == '' ]] ; then
  465. -       regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
  466. +               regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
  467.         fi
  468.  
  469.         # disable DFS
  470. @@ -448,7 +532,7 @@ function nfsclient_adddriver
  471.         if is_windows_64bit ; then
  472.                 # copy from the 32bit install dir
  473.                 rm -f '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
  474. -               cp './i686/nfs41_np.dll' '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
  475. +               cp './i686/nfs41_np.release.dll' '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
  476.         fi
  477.  
  478.         return 0
  479. @@ -1070,8 +1154,6 @@ function main
  480.                         check_machine_arch || (( numerr++ ))
  481.                         require_cmd 'regtool.exe' || (( numerr++ ))
  482.                         require_cmd 'cygrunsrv.exe' || (( numerr++ ))
  483. -                       require_cmd 'nfsd.exe' || (( numerr++ ))
  484. -                       require_cmd 'nfs_install.exe' || (( numerr++ ))
  485.                         require_cmd 'rundll32.exe' || (( numerr++ ))
  486.                         require_cmd 'bcdedit.exe' || (( numerr++ ))
  487.                         require_cmd 'fsutil.exe' || (( numerr++ ))
  488. @@ -1130,7 +1212,6 @@ function main
  489.                         check_machine_arch || (( numerr++ ))
  490.                         #require_cmd 'cdb.exe' || (( numerr++ ))
  491.                         require_cmd 'nfsd.exe' || (( numerr++ ))
  492. -                       require_cmd 'nfsd_debug.exe' || (( numerr++ ))
  493.                         require_cmd 'nfs_mount.exe' || (( numerr++ ))
  494.                         require_cmd 'ksh93.exe' || (( numerr++ ))
  495.                         require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
  496. @@ -1144,7 +1225,6 @@ function main
  497.                         #require_cmd 'cdb.exe' || (( numerr++ ))
  498.                         require_cmd 'PsExec.exe' || (( numerr++ ))
  499.                         require_cmd 'nfsd.exe' || (( numerr++ ))
  500. -                       require_cmd 'nfsd_debug.exe' || (( numerr++ ))
  501.                         require_cmd 'nfs_mount.exe' || (( numerr++ ))
  502.                         require_cmd 'ksh93.exe' || (( numerr++ ))
  503.                         require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
  504. --
  505. 2.51.0
  506.  
  507. From f0b43078cc68a0031c544c5bcd57f8ca107e31cf Mon Sep 17 00:00:00 2001
  508. From: Roland Mainz <roland.mainz@nrubsig.org>
  509. Date: Wed, 24 Sep 2025 19:18:10 +0200
  510. Subject: [PATCH 2/6] libtirpc: Codepath for |CRITICAL_SECTION|-as-mutex should
  511.  use |spincount=0| on the lock
  512.  
  513. Codepath for |CRITICAL_SECTION|-as-mutex should use |spincount=0| on
  514. the lock, as all users wait for a long time on the mutex anyway.
  515.  
  516. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  517. ---
  518. libtirpc/tirpc/reentrant.h | 2 +-
  519.  1 file changed, 1 insertion(+), 1 deletion(-)
  520.  
  521. diff --git a/libtirpc/tirpc/reentrant.h b/libtirpc/tirpc/reentrant.h
  522. index 9e6b102..ee25946 100644
  523. --- a/libtirpc/tirpc/reentrant.h
  524. +++ b/libtirpc/tirpc/reentrant.h
  525. @@ -152,7 +152,7 @@
  526.  #define mutex_unlock(m)                ReleaseSRWLockExclusive(m)
  527.  #define mutex_trylock(m)       TryAcquireSRWLockExclusive(m)
  528.  #else
  529. -#define mutex_init(m, a)       InitializeCriticalSection(m)
  530. +#define mutex_init(m, a)       InitializeCriticalSectionAndSpinCount((m), 0)
  531.  #define mutex_lock(m)          EnterCriticalSection(m)
  532.  #define mutex_unlock(m)                LeaveCriticalSection(m)
  533.  #define mutex_trylock(m)       TryEnterCriticalSection(m)
  534. --
  535. 2.51.0
  536.  
  537. From 276863a46ae9b256a96f02047c06be420925cc68 Mon Sep 17 00:00:00 2001
  538. From: Roland Mainz <roland.mainz@nrubsig.org>
  539. Date: Wed, 24 Sep 2025 19:29:00 +0200
  540. Subject: [PATCH 3/6] cygwin: Use "manual driver install" codepath instead of
  541.  nfs41rdr.inf for Win11/ARM64 support
  542.  
  543. Use "manual driver install" codepath instead of nfs41rdr.inf for
  544. Windows 11/ARM64 support, because our current nfs41rdr.inf fails
  545. to work on Windows 11/ARM64.
  546.  
  547. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  548. ---
  549. cygwin/devel/msnfs41client.bash | 8 ++++++--
  550.  1 file changed, 6 insertions(+), 2 deletions(-)
  551.  
  552. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  553. index 975e089..8d5cfd0 100755
  554. --- a/cygwin/devel/msnfs41client.bash
  555. +++ b/cygwin/devel/msnfs41client.bash
  556. @@ -465,8 +465,6 @@ function nfsclient_disable_autostartservices
  557.         sc config 'ms-nfs41-client-globalmountall-service' start=disabled
  558.  }
  559.  
  560. -typeset -r use_nfs41rdrinf=true
  561. -
  562.  function nfsclient_adddriver
  563.  {
  564.         typeset -i res
  565. @@ -1349,6 +1347,12 @@ function main
  566.  #
  567.  # main
  568.  #
  569. +
  570. +# Our current nfs41rdr.inf file does not work on Windows 11/ARM64,
  571. +# therefore use the "manual driver install" codepath for now
  572. +# until we fixed the nfs41rdr.inf
  573. +typeset -r use_nfs41rdrinf=false
  574. +
  575.  if [[ -v KSH_VERSION ]] ; then
  576.         #
  577.         # use ksh93 builtins
  578. --
  579. 2.51.0
  580.  
  581. From 72b7575ad72191efa1d87f32f7bcebf43f0ae320 Mon Sep 17 00:00:00 2001
  582. From: Roland Mainz <roland.mainz@nrubsig.org>
  583. Date: Wed, 24 Sep 2025 20:55:33 +0200
  584. Subject: [PATCH 4/6] daemon,sys: Add asserts that all data from kernel are
  585.  read+fix kernel
  586.  
  587. Add asserts that all data from kernel are read, and fix related issues
  588. in the kernel module.
  589.  
  590. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  591. ---
  592. daemon/acl.c            | 10 +++++++++-
  593.  daemon/ea.c             | 14 ++++++++++++--
  594.  daemon/fsctl.c          |  6 ++++++
  595.  daemon/getattr.c        |  2 ++
  596.  daemon/lock.c           |  4 ++++
  597.  daemon/mount.c          |  5 +++++
  598.  daemon/open.c           |  6 ++++++
  599.  daemon/readdir.c        |  3 +++
  600.  daemon/readwrite.c      |  2 ++
  601.  daemon/setattr.c        |  3 ++-
  602.  daemon/symlink.c        |  4 ++++
  603.  daemon/util.c           | 17 +++++++++++++++++
  604.  daemon/util.h           |  2 ++
  605.  daemon/volume.c         |  2 ++
  606.  sys/nfs41sys_fileinfo.c |  7 ++-----
  607.  sys/nfs41sys_fsctl.c    |  2 +-
  608.  16 files changed, 79 insertions(+), 10 deletions(-)
  609.  
  610. diff --git a/daemon/acl.c b/daemon/acl.c
  611. index 56d297a..7b68f7c 100644
  612. --- a/daemon/acl.c
  613. +++ b/daemon/acl.c
  614. @@ -64,6 +64,8 @@ static int parse_getacl(unsigned char *buffer, uint32_t length,
  615.      status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
  616.      if (status) goto out;
  617.  
  618. +    EASSERT(length == 0);
  619. +
  620.      DPRINTF(1, ("parsing NFS41_SYSOP_ACL_QUERY: info_class=%d\n", args->query));
  621.  out:
  622.      return status;
  623. @@ -521,13 +523,19 @@ static int parse_setacl(unsigned char *buffer, uint32_t length,
  624.  {
  625.      int status;
  626.      setacl_upcall_args *args = &upcall->args.setacl;
  627. +    void *sec_desc_ptr = NULL;
  628.      ULONG sec_desc_len;
  629.  
  630.      status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
  631.      if (status) goto out;
  632.      status = safe_read(&buffer, &length, &sec_desc_len, sizeof(ULONG));
  633.      if (status) goto out;
  634. -    args->sec_desc = (PSECURITY_DESCRIPTOR)buffer;
  635. +    status = get_safe_read_bufferpos(&buffer, &length, sec_desc_len, &sec_desc_ptr);
  636. +    if (status) goto out;
  637. +
  638. +    args->sec_desc = (PSECURITY_DESCRIPTOR)sec_desc_ptr;
  639. +
  640. +    EASSERT(length == 0);
  641.  
  642.      DPRINTF(1, ("parsing NFS41_SYSOP_ACL_SET: info_class=%d sec_desc_len=%d\n",
  643.              args->query, sec_desc_len));
  644. diff --git a/daemon/ea.c b/daemon/ea.c
  645. index a1fb42f..14a2fee 100644
  646. --- a/daemon/ea.c
  647. +++ b/daemon/ea.c
  648. @@ -198,7 +198,9 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  649.      if (status) goto out;
  650.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  651.      if (status) goto out;
  652. -    args->buf = buffer;
  653. +    status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  654. +
  655. +    EASSERT(length == 0);
  656.  
  657.      DPRINTF(1, ("parsing NFS41_SYSOP_EA_SET: mode=0%o\n", args->mode));
  658.  out:
  659. @@ -271,7 +273,15 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  660.      if (status) goto out;
  661.      status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
  662.      if (status) goto out;
  663. -    args->ealist = args->ealist_len ? buffer : NULL;
  664. +    if (args->ealist_len) {
  665. +        status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
  666. +        if (status) goto out;
  667. +    }
  668. +    else {
  669. +        args->ealist = NULL;
  670. +    }
  671. +
  672. +    EASSERT(length == 0);
  673.  
  674.      DPRINTF(1, ("parsing NFS41_SYSOP_EA_GET: buf_len=%d Index %d Restart %d "
  675.          "Single %d\n", args->buf_len,args->eaindex, args->restart, args->single));
  676. diff --git a/daemon/fsctl.c b/daemon/fsctl.c
  677. index c730ab2..dbc76f6 100644
  678. --- a/daemon/fsctl.c
  679. +++ b/daemon/fsctl.c
  680. @@ -44,6 +44,8 @@ static int parse_queryallocatedranges(unsigned char *buffer,
  681.      status = safe_read(&buffer, &length, &args->outbuffer, sizeof(args->outbuffer));
  682.      if (status) goto out;
  683.  
  684. +    EASSERT(length == 0);
  685. +
  686.      DPRINTF(QARLVL, ("parse_queryallocatedranges: "
  687.          "parsing '%s' inrange=(FileOffset=%lld Length=%lld) "
  688.          "outbuffersize=%lu outbuffer=0x%p\n",
  689. @@ -327,6 +329,8 @@ static int parse_setzerodata(unsigned char *buffer,
  690.          sizeof(args->setzerodata));
  691.      if (status) goto out;
  692.  
  693. +    EASSERT(length == 0);
  694. +
  695.      DPRINTF(SZDLVL, ("parse_setzerodata: "
  696.          "parsing '%s' setzerodata=(FileOffset=%lld BeyondFinalZero=%lld)\n",
  697.          opcode2string(upcall->opcode),
  698. @@ -453,6 +457,8 @@ static int parse_duplicatedata(unsigned char *buffer,
  699.          sizeof(args->bytecount));
  700.      if (status) goto out;
  701.  
  702. +    EASSERT(length == 0);
  703. +
  704.      DPRINTF(DDLVL, ("parse_duplicatedata: "
  705.          "parsing '%s' "
  706.          "duplicatedata=(src_state=0x%p srcfileoffset=%lld "
  707. diff --git a/daemon/getattr.c b/daemon/getattr.c
  708. index f057eab..f5622d2 100644
  709. --- a/daemon/getattr.c
  710. +++ b/daemon/getattr.c
  711. @@ -93,6 +93,8 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
  712.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  713.      if (status) goto out;
  714.  
  715. +    EASSERT(length == 0);
  716. +
  717.      DPRINTF(1, ("parsing '%s': "
  718.          "info_class=%d buf_len=%d file='%.*s'\n",
  719.          opcode2string(upcall->opcode),
  720. diff --git a/daemon/lock.c b/daemon/lock.c
  721. index efaf40a..0c9a85b 100644
  722. --- a/daemon/lock.c
  723. +++ b/daemon/lock.c
  724. @@ -181,6 +181,8 @@ static int parse_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
  725.      status = safe_read(&buffer, &length, &args->blocking, sizeof(BOOLEAN));
  726.      if (status) goto out;
  727.  
  728. +    EASSERT(length == 0);
  729. +
  730.      DPRINTF(1, ("parsing NFS41_SYSOP_LOCK: offset=0x%llx length=0x%llx exclusive=%u "
  731.              "blocking=%u\n", args->offset, args->length, args->exclusive,
  732.              args->blocking));
  733. @@ -311,6 +313,8 @@ static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *up
  734.      status = safe_read(&buffer, &length, &args->count, sizeof(ULONG));
  735.      if (status) goto out;
  736.  
  737. +    EASSERT(length == 0);
  738. +
  739.      args->buf = buffer;
  740.      args->buf_len = length;
  741.  
  742. diff --git a/daemon/mount.c b/daemon/mount.c
  743. index 3864b4a..2105375 100644
  744. --- a/daemon/mount.c
  745. +++ b/daemon/mount.c
  746. @@ -64,6 +64,8 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
  747.      if (status) goto out;
  748.  #endif /* NFS41_DRIVER_HACK_FORCE_FILENAME_CASE_MOUNTOPTIONS */
  749.  
  750. +    EASSERT(length == 0);
  751. +
  752.  #ifdef NFS41_DRIVER_HACK_FORCE_FILENAME_CASE_MOUNTOPTIONS
  753.      DPRINTF(1, ("parsing NFS41_SYSOP_MOUNT: hostport='%s' root='%s' "
  754.          "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d "
  755. @@ -347,6 +349,9 @@ const nfs41_upcall_op nfs41_op_mount = {
  756.  static int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
  757.  {
  758.      DPRINTF(1, ("parsing NFS41_SYSOP_UNMOUNT: root=0x%p\n", upcall->root_ref));
  759. +
  760. +    EASSERT(length == 0);
  761. +
  762.      return ERROR_SUCCESS;
  763.  }
  764.  
  765. diff --git a/daemon/open.c b/daemon/open.c
  766. index 593452c..75740ef 100644
  767. --- a/daemon/open.c
  768. +++ b/daemon/open.c
  769. @@ -344,6 +344,10 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
  770.      status = safe_read(&buffer, &length, &args->ea, sizeof(HANDLE));
  771.      if (status) goto out;
  772.  
  773. +    EASSERT_MSG((length == 0),
  774. +        ("parse_open: filename='%s' leftover length=%ld\n",
  775. +        args->path, (long)length));
  776. +
  777.      DPRINTF(1, ("parsing NFS41_SYSOP_OPEN: filename='%s' "
  778.          "isvolumemntpt=%d access mask=%d "
  779.          "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
  780. @@ -1351,6 +1355,8 @@ static int parse_close(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
  781.          if (status) goto out;
  782.      }
  783.  
  784. +    EASSERT(length == 0);
  785. +
  786.      DPRINTF(1,
  787.          ("parsing NFS41_SYSOP_CLOSE: "
  788.          "remove=%d srv_open=0x%p renamed=%d "
  789. diff --git a/daemon/readdir.c b/daemon/readdir.c
  790. index e7ba90c..83d848e 100644
  791. --- a/daemon/readdir.c
  792. +++ b/daemon/readdir.c
  793. @@ -282,6 +282,9 @@ static int parse_readdir(unsigned char *buffer, uint32_t length, nfs41_upcall *u
  794.      if (status) goto out;
  795.      status = safe_read(&buffer, &length, &args->kbuf, sizeof(args->kbuf));
  796.      if (status) goto out;
  797. +
  798. +    EASSERT(length == 0);
  799. +
  800.      args->root = upcall->root_ref;
  801.      args->state = upcall->state_ref;
  802.  
  803. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  804. index 3c52049..2be92b6 100644
  805. --- a/daemon/readwrite.c
  806. +++ b/daemon/readwrite.c
  807. @@ -50,6 +50,8 @@ static int parse_rw(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall
  808.      status = safe_read(&buffer, &length, &args->buffer, sizeof(args->buffer));
  809.      if (status) goto out;
  810.  
  811. +    EASSERT(length == 0);
  812. +
  813.      DPRINTF(1, ("parsing '%s' len=%lu offset=%llu buf=0x%p\n",
  814.              opcode2string(upcall->opcode), args->len, args->offset, args->buffer));
  815.  out:
  816. diff --git a/daemon/setattr.c b/daemon/setattr.c
  817. index db45478..9f379f1 100644
  818. --- a/daemon/setattr.c
  819. +++ b/daemon/setattr.c
  820. @@ -53,8 +53,9 @@ static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
  821.      if (status) goto out;
  822.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  823.      if (status) goto out;
  824. +    status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  825. +    if (status) goto out;
  826.  
  827. -    args->buf = buffer;
  828.      args->root = upcall->root_ref;
  829.      args->state = upcall->state_ref;
  830.  
  831. diff --git a/daemon/symlink.c b/daemon/symlink.c
  832. index 0537380..ee12c16 100644
  833. --- a/daemon/symlink.c
  834. +++ b/daemon/symlink.c
  835. @@ -246,6 +246,8 @@ static int parse_symlink_get(unsigned char *buffer, uint32_t length,
  836.      if (status)
  837.          goto out;
  838.  
  839. +    EASSERT(length == 0);
  840. +
  841.      args->target_set = NULL;
  842.  
  843.      DPRINTF(SYMLLVL1,
  844. @@ -345,6 +347,8 @@ static int parse_symlink_set(unsigned char *buffer, uint32_t length,
  845.      status = get_name(&buffer, &length,
  846.          (const char **)(&args->target_set));
  847.  
  848. +    EASSERT(length == 0);
  849. +
  850.      DPRINTF(SYMLLVL1,
  851.          ("parse_symlink_set: parsing NFS41_SYSOP_SYMLINK_SET: "
  852.          "path='%s' target='%s'\n",
  853. diff --git a/daemon/util.c b/daemon/util.c
  854. index 37660d2..31cdb4d 100644
  855. --- a/daemon/util.c
  856. +++ b/daemon/util.c
  857. @@ -50,6 +50,23 @@ int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t des
  858.      return 0;
  859.  }
  860.  
  861. +/*
  862. + * |get_safe_read_bufferpos()| - like |safe_read()| but tests whether we
  863. + * have enough buffer space left, and in that case return current buffer
  864. + * position in |destbuffer|
  865. + */
  866. +int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t src_len, void **destbuffer)
  867. +{
  868. +    if (*remaining < src_len)
  869. +        return ERROR_BUFFER_OVERFLOW;
  870. +
  871. +    *destbuffer = *pos;
  872. +    *pos += src_len;
  873. +    *remaining -= src_len;
  874. +    return ERROR_SUCCESS;
  875. +}
  876. +
  877. +
  878.  int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src_len)
  879.  {
  880.      if (*remaining < src_len)
  881. diff --git a/daemon/util.h b/daemon/util.h
  882. index 6a7f458..83b925d 100644
  883. --- a/daemon/util.h
  884. +++ b/daemon/util.h
  885. @@ -94,6 +94,8 @@ void *memrchr(const void * restrict s, int c, size_t n)
  886.  }
  887.  
  888.  int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
  889. +int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining,
  890. +    uint32_t src_len, void **destbuffer);
  891.  int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
  892.  int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining,
  893.      uint32_t src_len, void **destbuffer);
  894. diff --git a/daemon/volume.c b/daemon/volume.c
  895. index 3501c6e..2eb29bc 100644
  896. --- a/daemon/volume.c
  897. +++ b/daemon/volume.c
  898. @@ -53,6 +53,8 @@ static int parse_volume(unsigned char *buffer, uint32_t length, nfs41_upcall *up
  899.      status = safe_read(&buffer, &length, &args->query, sizeof(FS_INFORMATION_CLASS));
  900.      if (status) goto out;
  901.  
  902. +    EASSERT(length == 0);
  903. +
  904.      DPRINTF(1, ("parsing NFS41_SYSOP_VOLUME_QUERY: query=%d\n", args->query));
  905.  out:
  906.      return status;
  907. diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
  908. index 0b148f8..b4cd89f 100644
  909. --- a/sys/nfs41sys_fileinfo.c
  910. +++ b/sys/nfs41sys_fileinfo.c
  911. @@ -83,7 +83,7 @@ NTSTATUS marshal_nfs41_filequery(
  912.      if (status) goto out;
  913.      else tmp += *len;
  914.  
  915. -    header_len = *len + 2 * sizeof(ULONG) + 2*sizeof(HANDLE);
  916. +    header_len = *len + 2 * sizeof(ULONG);
  917.      if (header_len > buf_len) {
  918.          status = STATUS_INSUFFICIENT_RESOURCES;
  919.          goto out;
  920. @@ -91,10 +91,7 @@ NTSTATUS marshal_nfs41_filequery(
  921.      RtlCopyMemory(tmp, &entry->u.QueryFile.InfoClass, sizeof(ULONG));
  922.      tmp += sizeof(ULONG);
  923.      RtlCopyMemory(tmp, &entry->buf_len, sizeof(ULONG));
  924. -    tmp += sizeof(ULONG);
  925. -    RtlCopyMemory(tmp, &entry->session, sizeof(HANDLE));
  926. -    tmp += sizeof(HANDLE);
  927. -    RtlCopyMemory(tmp, &entry->open_state, sizeof(HANDLE));
  928. +    /* tmp += sizeof(ULONG); */
  929.      *len = header_len;
  930.  
  931.  #ifdef DEBUG_MARSHAL_DETAIL
  932. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  933. index b65d35b..8f25517 100644
  934. --- a/sys/nfs41sys_fsctl.c
  935. +++ b/sys/nfs41sys_fsctl.c
  936. @@ -256,7 +256,7 @@ NTSTATUS marshal_nfs41_queryallocatedranges(
  937.      else tmp += *len;
  938.  
  939.      header_len = *len + sizeof(FILE_ALLOCATED_RANGE_BUFFER) +
  940. -        sizeof(LONGLONG) +
  941. +        sizeof(ULONG) +
  942.          sizeof(HANDLE);
  943.      if (header_len > buf_len) {
  944.          status = STATUS_INSUFFICIENT_RESOURCES;
  945. --
  946. 2.51.0
  947.  
  948. From 28b1ca4505a257f32fd7ec249f0de2c5cc2363a8 Mon Sep 17 00:00:00 2001
  949. From: Roland Mainz <roland.mainz@nrubsig.org>
  950. Date: Wed, 24 Sep 2025 21:25:37 +0200
  951. Subject: [PATCH 5/6] daemon:
  952.  |get_safe_read_bufferpos()|+|get_write_read_bufferpos()| should return |NULL|
  953.  ptr if |len==0|
  954.  
  955. |get_safe_read_bufferpos()|+|get_write_read_bufferpos()| should return
  956. |NULL| pointer if |len==0|.
  957.  
  958. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  959. ---
  960. daemon/acl.c     |  8 +++++++-
  961.  daemon/ea.c      | 15 ++++++++-------
  962.  daemon/setattr.c |  6 ++++++
  963.  daemon/util.c    |  4 ++--
  964.  4 files changed, 23 insertions(+), 10 deletions(-)
  965.  
  966. diff --git a/daemon/acl.c b/daemon/acl.c
  967. index 7b68f7c..b56266c 100644
  968. --- a/daemon/acl.c
  969. +++ b/daemon/acl.c
  970. @@ -523,7 +523,7 @@ static int parse_setacl(unsigned char *buffer, uint32_t length,
  971.  {
  972.      int status;
  973.      setacl_upcall_args *args = &upcall->args.setacl;
  974. -    void *sec_desc_ptr = NULL;
  975. +    void *sec_desc_ptr;
  976.      ULONG sec_desc_len;
  977.  
  978.      status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
  979. @@ -1437,6 +1437,12 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  980.      DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s')\n",
  981.          state->path.path));
  982.  
  983. +    if (args->sec_desc == NULL) {
  984. +        eprintf("handle_setacl: args->sec_desc==NULL\n");
  985. +        status = ERROR_INVALID_PARAMETER;
  986. +        goto out;
  987. +    }
  988. +
  989.      if (args->query & OWNER_SECURITY_INFORMATION) {
  990.          DPRINTF(ACLLVL2, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
  991.          status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
  992. diff --git a/daemon/ea.c b/daemon/ea.c
  993. index 14a2fee..0915790 100644
  994. --- a/daemon/ea.c
  995. +++ b/daemon/ea.c
  996. @@ -215,6 +215,12 @@ static int handle_setexattr(void *daemon_context, nfs41_upcall *upcall)
  997.      PFILE_FULL_EA_INFORMATION ea =
  998.          (PFILE_FULL_EA_INFORMATION)args->buf;
  999.  
  1000. +    if (ea == NULL) {
  1001. +        eprintf("handle_setexattr: ea==NULL\n");
  1002. +        status = ERROR_INVALID_PARAMETER;
  1003. +        goto out;
  1004. +    }
  1005. +
  1006.      /* break read delegations before SETATTR */
  1007.      nfs41_delegation_return(state->session, &state->file,
  1008.          OPEN_DELEGATE_READ, FALSE);
  1009. @@ -273,13 +279,8 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  1010.      if (status) goto out;
  1011.      status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
  1012.      if (status) goto out;
  1013. -    if (args->ealist_len) {
  1014. -        status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
  1015. -        if (status) goto out;
  1016. -    }
  1017. -    else {
  1018. -        args->ealist = NULL;
  1019. -    }
  1020. +    status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
  1021. +    if (status) goto out;
  1022.  
  1023.      EASSERT(length == 0);
  1024.  
  1025. diff --git a/daemon/setattr.c b/daemon/setattr.c
  1026. index 9f379f1..c6933d4 100644
  1027. --- a/daemon/setattr.c
  1028. +++ b/daemon/setattr.c
  1029. @@ -78,6 +78,12 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
  1030.      (void)memset(&info, 0, sizeof(info));
  1031.      (void)memset(&old_info, 0, sizeof(old_info));
  1032.  
  1033. +    if (basic_info == NULL) {
  1034. +        eprintf("handle_nfs41_setattr_basicinfo: basic_info==NULL\n");
  1035. +        status = ERROR_INVALID_PARAMETER;
  1036. +        goto out;
  1037. +    }
  1038. +
  1039.      getattr_status = nfs41_cached_getattr(state->session,
  1040.          &state->file, NULL, &old_info);
  1041.      if (getattr_status) {
  1042. diff --git a/daemon/util.c b/daemon/util.c
  1043. index 31cdb4d..6e26e83 100644
  1044. --- a/daemon/util.c
  1045. +++ b/daemon/util.c
  1046. @@ -60,7 +60,7 @@ int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t s
  1047.      if (*remaining < src_len)
  1048.          return ERROR_BUFFER_OVERFLOW;
  1049.  
  1050. -    *destbuffer = *pos;
  1051. +    *destbuffer = (src_len == 0)?NULL:*pos;
  1052.      *pos += src_len;
  1053.      *remaining -= src_len;
  1054.      return ERROR_SUCCESS;
  1055. @@ -88,7 +88,7 @@ int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t
  1056.      if (*remaining < src_len)
  1057.          return ERROR_BUFFER_OVERFLOW;
  1058.  
  1059. -    *destbuffer = *pos;
  1060. +    *destbuffer = (src_len == 0)?NULL:*pos;
  1061.      *pos += src_len;
  1062.      *remaining -= src_len;
  1063.      return ERROR_SUCCESS;
  1064. --
  1065. 2.51.0
  1066.  
  1067. From 20780dfa45f7c808ad1696a8cf2f7c20ba6a8820 Mon Sep 17 00:00:00 2001
  1068. From: Roland Mainz <roland.mainz@nrubsig.org>
  1069. Date: Wed, 24 Sep 2025 21:34:30 +0200
  1070. Subject: [PATCH 6/6] daemon: Fix
  1071.  |get_safe_read_bufferpos()|+|get_safe_write_bufferpos()| caller error
  1072.  handling
  1073.  
  1074. Fix |get_safe_read_bufferpos()|+|get_safe_write_bufferpos()| caller error
  1075. handling.
  1076.  
  1077. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1078. ---
  1079. daemon/ea.c      | 1 +
  1080.  daemon/open.c    | 1 +
  1081.  daemon/symlink.c | 2 ++
  1082.  3 files changed, 4 insertions(+)
  1083.  
  1084. diff --git a/daemon/ea.c b/daemon/ea.c
  1085. index 0915790..795e242 100644
  1086. --- a/daemon/ea.c
  1087. +++ b/daemon/ea.c
  1088. @@ -199,6 +199,7 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  1089.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  1090.      if (status) goto out;
  1091.      status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  1092. +    if (status) goto out;
  1093.  
  1094.      EASSERT(length == 0);
  1095.  
  1096. diff --git a/daemon/open.c b/daemon/open.c
  1097. index 75740ef..953fa49 100644
  1098. --- a/daemon/open.c
  1099. +++ b/daemon/open.c
  1100. @@ -1263,6 +1263,7 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  1101.          status = get_safe_write_bufferpos(&buffer, length,
  1102.              sizeof(unsigned short), &wc_len_out);
  1103.          if (status) goto out;
  1104. +        EASSERT(wc_len_out != NULL);
  1105.  
  1106.          if (*length <= len) {
  1107.              status = ERROR_BUFFER_OVERFLOW;
  1108. diff --git a/daemon/symlink.c b/daemon/symlink.c
  1109. index ee12c16..5722b72 100644
  1110. --- a/daemon/symlink.c
  1111. +++ b/daemon/symlink.c
  1112. @@ -296,6 +296,8 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
  1113.      unsigned short *wc_len_out;
  1114.      status = get_safe_write_bufferpos(&buffer, length,
  1115.          sizeof(unsigned short), &wc_len_out);
  1116. +    if (status) goto out;
  1117. +    EASSERT(wc_len_out != NULL);
  1118.  
  1119.      if (*length <= len) {
  1120.          status = ERROR_BUFFER_OVERFLOW;
  1121. --
  1122. 2.51.0

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