pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for |FileFsAttributeInformation|, increased worker stack size, fixed rename with long paths, maxACEperACL increase to 128, 2025-07-16
Posted by Anonymous on Wed 16th Jul 2025 21:54
raw | new post

  1. From d1021d510c17037ad940e18b4bd4dea62f3b3479 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 16 Jul 2025 19:19:03 +0200
  4. Subject: [PATCH 1/4] daemon,include,sys: |FileFsAttributeInformation| should
  5.  always get correct filesystem information
  6.  
  7. |FileFsAttributeInformation| should always get correct filesystem information
  8. from the userland daemon+NFS server. This is neccesary in case of referrals,
  9. as the referred filesystem might have different properties and capabilities
  10. (i.e. NFSv4.2 filesystem mounted, and the referral is NFSv4.1, or different
  11. maximum name lengths etc.).
  12.  
  13. On the ToDo list is still a per NFSv4 FSID kernel cache for filesystem
  14. information to avoid updowncalls into the userland daemon if the matching
  15. FSID was already queried.
  16.  
  17. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  18. ---
  19. daemon/nfs41.h            |  6 +++---
  20.  daemon/nfs41_superblock.c | 16 +++++++++++++---
  21.  daemon/upcall.h           |  4 ++--
  22.  include/nfs41_driver.h    | 11 +++++++++++
  23.  sys/nfs41sys_driver.h     | 17 +++--------------
  24.  sys/nfs41sys_ea.c         |  4 ++--
  25.  sys/nfs41sys_mount.c      |  5 +++--
  26.  sys/nfs41sys_openclose.c  |  2 +-
  27.  sys/nfs41sys_util.c       |  2 +-
  28.  sys/nfs41sys_volinfo.c    | 37 -------------------------------------
  29.  10 files changed, 39 insertions(+), 65 deletions(-)
  30.  
  31. diff --git a/daemon/nfs41.h b/daemon/nfs41.h
  32. index e3443e7..5eb628c 100644
  33. --- a/daemon/nfs41.h
  34. +++ b/daemon/nfs41.h
  35. @@ -508,10 +508,10 @@ static __inline void nfs41_superblock_supported_attrs_exclcreat(
  36.      bitmap_intersect(attrs, &superblock->suppattr_exclcreat);
  37.  }
  38.  
  39. -struct _FILE_FS_ATTRIBUTE_INFORMATION;
  40. +struct _NFS41_FILE_FS_ATTRIBUTE_INFORMATION;
  41.  void nfs41_superblock_fs_attributes(
  42. -    IN const nfs41_superblock *superblock,
  43. -    OUT struct _FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs);
  44. +    IN const nfs41_superblock *restrict superblock,
  45. +    OUT struct _NFS41_FILE_FS_ATTRIBUTE_INFORMATION *restrict FsAttrs);
  46.  
  47.  void nfs41_superblock_space_changed(
  48.      IN nfs41_superblock *superblock);
  49. diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
  50. index 8b88bc0..671b8ce 100644
  51. --- a/daemon/nfs41_superblock.c
  52. +++ b/daemon/nfs41_superblock.c
  53. @@ -24,10 +24,12 @@
  54.  #include <Windows.h>
  55.  #include <stdio.h>
  56.  
  57. +#include "nfs41_build_features.h"
  58.  #include "daemon_debug.h"
  59.  #include "nfs41.h"
  60.  #include "nfs41_ops.h"
  61.  #include "from_kernel.h"
  62. +#include "nfs41_driver.h"
  63.  #include "util.h"
  64.  
  65.  
  66. @@ -176,8 +178,8 @@ out:
  67.  }
  68.  
  69.  void nfs41_superblock_fs_attributes(
  70. -    IN const nfs41_superblock *superblock,
  71. -    OUT PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs)
  72. +    IN const nfs41_superblock *restrict superblock,
  73. +    OUT NFS41_FILE_FS_ATTRIBUTE_INFORMATION *restrict FsAttrs)
  74.  {
  75.      /*
  76.       * |FileSystemAttributes| - general filesystem attributes
  77. @@ -212,7 +214,15 @@ void nfs41_superblock_fs_attributes(
  78.      FsAttrs->MaximumComponentNameLength = NFS41_MAX_COMPONENT_LEN;
  79.  
  80.      /* let the driver fill in FileSystemName */
  81. -    FsAttrs->FileSystemNameLength = 0;
  82. +#if ((NFS41_DRIVER_DEBUG_FS_NAME) == 1)
  83. +    (void)wcscpy(FsAttrs->FileSystemName, L"NFS");
  84. +    FsAttrs->FileSystemNameLength = 3*sizeof(wchar_t);
  85. +#elif  ((NFS41_DRIVER_DEBUG_FS_NAME) == 2)
  86. +    (void)wcscpy(FsAttrs->FileSystemName, L"DEBUG-NFS41");
  87. +    FsAttrs->FileSystemNameLength = 11*sizeof(wchar_t);
  88. +#else
  89. +#error NFS41_DRIVER_DEBUG_FS_NAME not defined
  90. +#endif
  91.  
  92.      DPRINTF(SBLVL, ("FileFsAttributeInformation: "
  93.          "link_support=%u, "
  94. diff --git a/daemon/upcall.h b/daemon/upcall.h
  95. index 05a9f40..2df7725 100644
  96. --- a/daemon/upcall.h
  97. +++ b/daemon/upcall.h
  98. @@ -41,7 +41,7 @@ typedef struct __mount_upcall_args {
  99.      DWORD       use_nfspubfh;
  100.      DWORD       nfsvers;
  101.      DWORD       lease_time;
  102. -    FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  103. +    NFS41_FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  104.  } mount_upcall_args;
  105.  
  106.  typedef struct __open_upcall_args {
  107. @@ -181,7 +181,7 @@ typedef struct __volume_upcall_args {
  108.          };
  109.  #pragma warning( pop )
  110.          FILE_FS_SIZE_INFORMATION size;
  111. -        FILE_FS_ATTRIBUTE_INFORMATION attribute;
  112. +        NFS41_FILE_FS_ATTRIBUTE_INFORMATION attribute;
  113.          FILE_FS_FULL_SIZE_INFORMATION fullsize;
  114.          FILE_FS_SECTOR_SIZE_INFORMATION sector_size;
  115.      } info;
  116. diff --git a/include/nfs41_driver.h b/include/nfs41_driver.h
  117. index e11ebf5..31dd4c8 100644
  118. --- a/include/nfs41_driver.h
  119. +++ b/include/nfs41_driver.h
  120. @@ -89,6 +89,17 @@ typedef enum _nfs41_opcodes {
  121.      NFS41_SYSOP_INVALID_OPCODE1
  122.  } nfs41_opcodes;
  123.  
  124. +/*
  125. + * Same as |FILE_FS_ATTRIBUTE_INFORMATION| but with inline buffer
  126. + * for 32 characters
  127. + */
  128. +typedef struct _NFS41_FILE_FS_ATTRIBUTE_INFORMATION {
  129. +    ULONG FileSystemAttributes;
  130. +    LONG MaximumComponentNameLength;
  131. +    ULONG FileSystemNameLength;
  132. +    WCHAR FileSystemName[32];
  133. +} NFS41_FILE_FS_ATTRIBUTE_INFORMATION;
  134. +
  135.  /*
  136.   * Symlink target path types returned by the |NFS41_SYSOP_OPEN|
  137.   * downcall
  138. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  139. index a40406d..3057e25 100644
  140. --- a/sys/nfs41sys_driver.h
  141. +++ b/sys/nfs41sys_driver.h
  142. @@ -190,7 +190,7 @@ typedef struct _updowncall_entry {
  143.          struct {
  144.              PUNICODE_STRING srv_name; /* hostname, or hostname@port */
  145.              PUNICODE_STRING root;
  146. -            PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  147. +            NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs;
  148.              DWORD sec_flavor;
  149.              DWORD rsize;
  150.              DWORD wsize;
  151. @@ -399,22 +399,11 @@ typedef struct _NFS41_NETROOT_EXTENSION {
  152.          (((pNetRoot) == NULL) ? NULL :          \
  153.          (PNFS41_NETROOT_EXTENSION)((pNetRoot)->Context))
  154.  
  155. -/* FileSystemName as reported by FileFsAttributeInfo query */
  156. -#if ((NFS41_DRIVER_DEBUG_FS_NAME) == 1)
  157. -#define FS_NAME     L"NFS"
  158. -#elif  ((NFS41_DRIVER_DEBUG_FS_NAME) == 2)
  159. -#define FS_NAME     L"DEBUG-NFS41"
  160. -#else
  161. -#error NFS41_DRIVER_DEBUG_FS_NAME not defined
  162. -#endif
  163. -#define FS_NAME_LEN (sizeof(FS_NAME) - sizeof(WCHAR))
  164. -#define FS_ATTR_LEN (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + FS_NAME_LEN)
  165. -
  166.  typedef struct _NFS41_V_NET_ROOT_EXTENSION {
  167.      NODE_TYPE_CODE          NodeTypeCode;
  168.      NODE_BYTE_SIZE          NodeByteSize;
  169.      HANDLE                  session;
  170. -    FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  171. +    NFS41_FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  172.      DWORD                   sec_flavor;
  173.      DWORD                   timeout;
  174.      NFS41_MOUNT_CREATEMODE  dir_createmode;
  175. @@ -727,7 +716,7 @@ NTSTATUS nfs41_mount(
  176.      DWORD sec_flavor,
  177.      PHANDLE session,
  178.      DWORD *version,
  179. -    PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs);
  180. +    NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs);
  181.  void nfs41_MountConfig_InitDefaults(
  182.      OUT PNFS41_MOUNT_CONFIG Config);
  183.  NTSTATUS nfs41_MountConfig_ParseOptions(
  184. diff --git a/sys/nfs41sys_ea.c b/sys/nfs41sys_ea.c
  185. index f8eac28..04447e8 100644
  186. --- a/sys/nfs41sys_ea.c
  187. +++ b/sys/nfs41sys_ea.c
  188. @@ -284,7 +284,7 @@ NTSTATUS check_nfs41_setea_args(
  189.      NTSTATUS status;
  190.      __notnull PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext =
  191.          NFS41GetVNetRootExtension(RxContext->pRelevantSrvOpen->pVNetRoot);
  192. -    __notnull PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs =
  193. +    __notnull NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs =
  194.          &pVNetRootContext->FsAttrs;
  195.      __notnull PFILE_FULL_EA_INFORMATION ea =
  196.          (PFILE_FULL_EA_INFORMATION)RxContext->Info.Buffer;
  197. @@ -423,7 +423,7 @@ NTSTATUS check_nfs41_queryea_args(
  198.      NTSTATUS status;
  199.      __notnull PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext =
  200.          NFS41GetVNetRootExtension(RxContext->pRelevantSrvOpen->pVNetRoot);
  201. -    __notnull PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs =
  202. +    __notnull NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs =
  203.          &pVNetRootContext->FsAttrs;
  204.      PFILE_GET_EA_INFORMATION ea = (PFILE_GET_EA_INFORMATION)
  205.              RxContext->CurrentIrpSp->Parameters.QueryEa.EaList;
  206. diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
  207. index f1d57da..181faca 100644
  208. --- a/sys/nfs41sys_mount.c
  209. +++ b/sys/nfs41sys_mount.c
  210. @@ -162,7 +162,8 @@ void unmarshal_nfs41_mount(
  211.      *buf += sizeof(DWORD);
  212.      RtlCopyMemory(&cur->u.Mount.lease_time, *buf, sizeof(DWORD));
  213.      *buf += sizeof(DWORD);
  214. -    RtlCopyMemory(cur->u.Mount.FsAttrs, *buf, sizeof(FILE_FS_ATTRIBUTE_INFORMATION));
  215. +    RtlCopyMemory(cur->u.Mount.FsAttrs, *buf,
  216. +        sizeof(NFS41_FILE_FS_ATTRIBUTE_INFORMATION));
  217.  #ifdef DEBUG_MARSHAL_DETAIL
  218.      DbgP("unmarshal_nfs41_mount: session=0x%p version=%d lease_time "
  219.           "%d\n",
  220. @@ -241,7 +242,7 @@ NTSTATUS nfs41_mount(
  221.      DWORD sec_flavor,
  222.      PHANDLE session,
  223.      DWORD *version,
  224. -    PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs)
  225. +    NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs)
  226.  {
  227.      NTSTATUS status = STATUS_INSUFFICIENT_RESOURCES;
  228.      nfs41_updowncall_entry *entry = NULL;
  229. diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
  230. index a5b5284..406c1bf 100644
  231. --- a/sys/nfs41sys_openclose.c
  232. +++ b/sys/nfs41sys_openclose.c
  233. @@ -474,7 +474,7 @@ NTSTATUS check_nfs41_create_args(
  234.      __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
  235.      __notnull PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext =
  236.          NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
  237. -    __notnull PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs =
  238. +    __notnull NFS41_FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs =
  239.          &pVNetRootContext->FsAttrs;
  240.      __notnull PNFS41_NETROOT_EXTENSION pNetRootContext =
  241.          NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
  242. diff --git a/sys/nfs41sys_util.c b/sys/nfs41sys_util.c
  243. index e0e4e8f..b1a7589 100644
  244. --- a/sys/nfs41sys_util.c
  245. +++ b/sys/nfs41sys_util.c
  246. @@ -73,7 +73,7 @@ BOOLEAN isFilenameTooLong(
  247.      PUNICODE_STRING name,
  248.      PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext)
  249.  {
  250. -    PFILE_FS_ATTRIBUTE_INFORMATION attrs = &pVNetRootContext->FsAttrs;
  251. +    NFS41_FILE_FS_ATTRIBUTE_INFORMATION *attrs = &pVNetRootContext->FsAttrs;
  252.      LONG len = attrs->MaximumComponentNameLength, count = 1, i;
  253.      PWCH p = name->Buffer;
  254.      for (i = 0; i < name->Length / 2; i++) {
  255. diff --git a/sys/nfs41sys_volinfo.c b/sys/nfs41sys_volinfo.c
  256. index d78a3da..1b1e470 100644
  257. --- a/sys/nfs41sys_volinfo.c
  258. +++ b/sys/nfs41sys_volinfo.c
  259. @@ -176,31 +176,6 @@ NTSTATUS nfs41_QueryVolumeInformation(
  260.      }
  261.  
  262.      case FileFsAttributeInformation:
  263. -        if (RxContext->Info.LengthRemaining < FS_ATTR_LEN) {
  264. -            RxContext->InformationToReturn = FS_ATTR_LEN;
  265. -            status = STATUS_BUFFER_TOO_SMALL;
  266. -            goto out;
  267. -        }
  268. -
  269. -        /* on attribute queries for the root directory,
  270. -         * use cached volume attributes from mount */
  271. -        if (is_root_directory(RxContext)) {
  272. -            PFILE_FS_ATTRIBUTE_INFORMATION attrs =
  273. -                (PFILE_FS_ATTRIBUTE_INFORMATION)RxContext->Info.Buffer;
  274. -            DECLARE_CONST_UNICODE_STRING(FsName, FS_NAME);
  275. -
  276. -            RtlCopyMemory(attrs, &pVNetRootContext->FsAttrs,
  277. -                sizeof(pVNetRootContext->FsAttrs));
  278. -
  279. -            /* fill in the FileSystemName */
  280. -            RtlCopyMemory(attrs->FileSystemName, FsName.Buffer,
  281. -                FsName.MaximumLength); /* 'MaximumLength' to include null */
  282. -            attrs->FileSystemNameLength = FsName.Length;
  283. -
  284. -            RxContext->Info.LengthRemaining -= FS_ATTR_LEN;
  285. -            goto out;
  286. -        }
  287. -        /* else fall through and send the upcall */
  288.      case FileFsSizeInformation:
  289.      case FileFsFullSizeInformation:
  290.      case FileFsSectorSizeInformation:
  291. @@ -232,18 +207,6 @@ NTSTATUS nfs41_QueryVolumeInformation(
  292.          RxContext->InformationToReturn = entry->buf_len;
  293.          status = STATUS_BUFFER_TOO_SMALL;
  294.      } else if (entry->status == STATUS_SUCCESS) {
  295. -        if (InfoClass == FileFsAttributeInformation) {
  296. -            /* fill in the FileSystemName */
  297. -            PFILE_FS_ATTRIBUTE_INFORMATION attrs =
  298. -                (PFILE_FS_ATTRIBUTE_INFORMATION)RxContext->Info.Buffer;
  299. -            DECLARE_CONST_UNICODE_STRING(FsName, FS_NAME);
  300. -
  301. -            RtlCopyMemory(attrs->FileSystemName, FsName.Buffer,
  302. -                FsName.MaximumLength); /* 'MaximumLength' to include null */
  303. -            attrs->FileSystemNameLength = FsName.Length;
  304. -
  305. -            entry->buf_len = FS_ATTR_LEN;
  306. -        }
  307.  #ifdef ENABLE_TIMINGS
  308.          InterlockedIncrement(&volume.sops);
  309.          InterlockedAdd64(&volume.size, entry->u.Volume.buf_len);
  310. --
  311. 2.45.1
  312.  
  313. From 71638104825eeac6988bda823fa5b0ce1c41aab1 Mon Sep 17 00:00:00 2001
  314. From: Roland Mainz <roland.mainz@nrubsig.org>
  315. Date: Wed, 16 Jul 2025 19:34:49 +0200
  316. Subject: [PATCH 2/4] daemon: Increase |UPCALL_BUF_SIZE| to properly fit two
  317.  paths for rename
  318.  
  319. Increase |UPCALL_BUF_SIZE| to properly fit two paths for rename.
  320.  
  321. Reported-by: Josh Hurst <joshhurst@gmail.com>
  322. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  323. ---
  324. daemon/nfs41_const.h | 8 +++++---
  325.  daemon/setattr.c     | 8 ++++++++
  326.  2 files changed, 13 insertions(+), 3 deletions(-)
  327.  
  328. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  329. index 02e7954..8dfb99e 100644
  330. --- a/daemon/nfs41_const.h
  331. +++ b/daemon/nfs41_const.h
  332. @@ -56,10 +56,12 @@
  333.  
  334.  /*
  335.   * UPCALL_BUF_SIZE - buffer size for |DeviceIoControl()|
  336. - * This must fit at least twice the maximum path length
  337. - * (for rename) plus header
  338. + *
  339. + * Size requirements:
  340. + * - This must fit at least twice (for rename) the maximum path length
  341. + * (see |NFS41_MAX_PATH_LEN| below) plus header
  342.   */
  343. -#define UPCALL_BUF_SIZE         ((2*4096)+1024)
  344. +#define UPCALL_BUF_SIZE     (16384)
  345.  
  346.  /*
  347.   * NFS41_MAX_COMPONENT_LEN - MaximumComponentNameLength
  348. diff --git a/daemon/setattr.c b/daemon/setattr.c
  349. index dcd5c4a..e4926a4 100644
  350. --- a/daemon/setattr.c
  351. +++ b/daemon/setattr.c
  352. @@ -33,6 +33,14 @@
  353.  #include "util.h"
  354.  #include "daemon_debug.h"
  355.  
  356. +/*
  357. + * |UPCALL_BUF_SIZE| must fit at least twice (for rename) the
  358. + * maximum path length plus header
  359. + */
  360. +#if UPCALL_BUF_SIZE < ((NFS41_MAX_PATH_LEN*2)+2048)
  361. +#error UPCALL_BUF_SIZE too small for rename ((NFS41_MAX_PATH_LEN*2)+2048)
  362. +#endif
  363. +
  364.  
  365.  /* NFS41_SYSOP_FILE_SET */
  366.  static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
  367. --
  368. 2.45.1
  369.  
  370. From 4440cde951371afa023052194e01072ddaa3510b Mon Sep 17 00:00:00 2001
  371. From: Roland Mainz <roland.mainz@nrubsig.org>
  372. Date: Wed, 16 Jul 2025 21:39:11 +0200
  373. Subject: [PATCH 3/4] daemon: Increase worker thread default stack size to 4MB
  374.  
  375. Increase worker thread default stack size to 4MB.
  376.  
  377. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  378. ---
  379. daemon/delegation.c    | 7 ++++++-
  380.  daemon/nfs41_const.h   | 2 ++
  381.  daemon/nfs41_daemon.c  | 8 ++++++--
  382.  daemon/nfs41_session.c | 2 +-
  383.  daemon/pnfs_io.c       | 2 +-
  384.  5 files changed, 16 insertions(+), 5 deletions(-)
  385.  
  386. diff --git a/daemon/delegation.c b/daemon/delegation.c
  387. index 2cef326..378c690 100644
  388. --- a/daemon/delegation.c
  389. +++ b/daemon/delegation.c
  390. @@ -754,7 +754,12 @@ int nfs41_delegation_recall(
  391.      args->truncate = truncate;
  392.  
  393.      /* the callback thread can't make rpc calls, so spawn a separate thread */
  394. -    if (_beginthreadex(NULL, 0, delegation_recall_thread, args, 0, NULL) == 0) {
  395. +    if (_beginthreadex(NULL,
  396. +        NFSD_THREAD_STACK_SIZE,
  397. +        delegation_recall_thread,
  398. +        args,
  399. +        0,
  400. +        NULL) == 0) {
  401.          status = NFS4ERR_SERVERFAULT;
  402.          eprintf("nfs41_delegation_recall() failed to start thread\n");
  403.          goto out_args;
  404. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  405. index 8dfb99e..108d6ed 100644
  406. --- a/daemon/nfs41_const.h
  407. +++ b/daemon/nfs41_const.h
  408. @@ -36,6 +36,8 @@
  409.  #define NFS4_EASIZE             2048
  410.  #define NFS4_EANAME_SIZE        128
  411.  
  412. +#define NFSD_THREAD_STACK_SIZE (4*1024*1024)
  413. +
  414.  /* Maximum number of AUP GIDs for |AUTH_UNIX| */
  415.  #define RPC_AUTHUNIX_AUP_MAX_NUM_GIDS 16
  416.  
  417. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  418. index f8d62d5..12d18b0 100644
  419. --- a/daemon/nfs41_daemon.c
  420. +++ b/daemon/nfs41_daemon.c
  421. @@ -878,8 +878,12 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  422.      DPRINTF(1, ("Starting %d worker threads...\n",
  423.          (int)nfs41_dg.num_worker_threads));
  424.      for (i = 0; i < nfs41_dg.num_worker_threads; i++) {
  425. -        tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, nfsd_thread_main,
  426. -                &nfs41_dg, 0, &tids[i].tid);
  427. +        tids[i].handle = (HANDLE)_beginthreadex(NULL,
  428. +            NFSD_THREAD_STACK_SIZE,
  429. +            nfsd_thread_main,
  430. +            &nfs41_dg,
  431. +            0,
  432. +            &tids[i].tid);
  433.          if (tids[i].handle == INVALID_HANDLE_VALUE) {
  434.              status = GetLastError();
  435.              eprintf("_beginthreadex failed %d\n", status);
  436. diff --git a/daemon/nfs41_session.c b/daemon/nfs41_session.c
  437. index 57dc186..b199138 100644
  438. --- a/daemon/nfs41_session.c
  439. +++ b/daemon/nfs41_session.c
  440. @@ -420,7 +420,7 @@ int nfs41_session_set_lease(
  441.          goto out;
  442.      }
  443.      session->renew.thread_handle = (HANDLE)_beginthreadex(NULL,
  444. -        0, renew_session_thread, session, 0, &thread_id);
  445. +        NFSD_THREAD_STACK_SIZE, renew_session_thread, session, 0, &thread_id);
  446.      if (!valid_handle(session->renew.thread_handle)) {
  447.          status = GetLastError();
  448.          eprintf("nfs41_session_set_lease: _beginthreadex() failed %d\n",
  449. diff --git a/daemon/pnfs_io.c b/daemon/pnfs_io.c
  450. index 54eb479..51225f3 100644
  451. --- a/daemon/pnfs_io.c
  452. +++ b/daemon/pnfs_io.c
  453. @@ -409,7 +409,7 @@ static enum pnfs_status pattern_fork(
  454.      }
  455.  
  456.      for (i = 0; i < pattern->count; i++) {
  457. -        threads[i] = (HANDLE)_beginthreadex(NULL, 0,
  458. +        threads[i] = (HANDLE)_beginthreadex(NULL, NFSD_THREAD_STACK_SIZE,
  459.              thread_fn, &pattern->threads[i], 0, NULL);
  460.          if (threads[i] == NULL) {
  461.              eprintf("_beginthreadex() failed with %d\n", GetLastError());
  462. --
  463. 2.45.1
  464.  
  465. From 58b73d4526815f40cd497eed3865b673f55a0cb2 Mon Sep 17 00:00:00 2001
  466. From: Roland Mainz <roland.mainz@nrubsig.org>
  467. Date: Wed, 16 Jul 2025 22:15:21 +0200
  468. Subject: [PATCH 4/4] daemon: Increase maximum number of ACE entries in an ACL
  469.  to 128
  470.  
  471. Increase maximum number of ACE entries in an ACL to 128, to handle
  472. enterprise users which use many ACEs.
  473.  
  474. Reported-by: Lionel Cons <lionelcons1972@gmail.com>
  475. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  476. ---
  477. daemon/lookup.c      |  4 ++--
  478.  daemon/nfs41_const.h | 19 +++++++++++++++++--
  479.  daemon/nfs41_ops.c   | 34 +++++++++++++++++-----------------
  480.  daemon/nfs41_types.h |  2 +-
  481.  daemon/nfs41_xdr.c   | 14 ++++++++++----
  482.  daemon/nfs42_ops.c   |  6 +++---
  483.  daemon/sid.c         |  2 +-
  484.  7 files changed, 51 insertions(+), 30 deletions(-)
  485.  
  486. diff --git a/daemon/lookup.c b/daemon/lookup.c
  487. index 45c8646..9d9cae4 100644
  488. --- a/daemon/lookup.c
  489. +++ b/daemon/lookup.c
  490. @@ -112,7 +112,7 @@ static void init_component_args(
  491.      res->root.path = path;
  492.      res->getrootfh.fh = &res->root.fh;
  493.      res->getrootattr.info = &res->rootinfo;
  494. -    res->getrootattr.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  495. +    res->getrootattr.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  496.      res->referral = referral;
  497.  
  498.      for (i = 0; i < MAX_LOOKUP_COMPONENTS; i++) {
  499. @@ -121,7 +121,7 @@ static void init_component_args(
  500.          args->lookup[i].name = &res->file[i].name;
  501.          res->getfh[i].fh = &res->file[i].fh;
  502.          res->getattr[i].info = &res->info[i];
  503. -        res->getattr[i].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  504. +        res->getattr[i].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  505.      }
  506.  }
  507.  
  508. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  509. index 108d6ed..524dd30 100644
  510. --- a/daemon/nfs41_const.h
  511. +++ b/daemon/nfs41_const.h
  512. @@ -31,6 +31,15 @@
  513.  #define NFS4_FHSIZE             128
  514.  #define NFS4_VERIFIER_SIZE      8
  515.  #define NFS4_OPAQUE_LIMIT       1024
  516. +/*
  517. + * |NFS4_OPAQUE_LIMIT_ATTR| for getattr/setattr
  518. + *
  519. + * Notes:
  520. + * - larger values consume more stack, a value of 8192 triggers a stack
  521. + * consumption which will not fit into the Win32 default stack size of 1MB
  522. + *
  523. + */
  524. +#define NFS4_OPAQUE_LIMIT_ATTR  (8192)
  525.  #define NFS4_SESSIONID_SIZE     16
  526.  #define NFS4_STATEID_OTHER      12
  527.  #define NFS4_EASIZE             2048
  528. @@ -50,8 +59,13 @@
  529.   */
  530.  #define NFS4_FATTR4_OWNER_LIMIT (256)
  531.  
  532. -/* Maximum number of ACLs per file/dir */
  533. -#define NFS41_ACL_MAX_ACE_ENTRIES (32)
  534. +/*
  535. + * |NFS41_ACL_MAX_ACE_ENTRIES| - Maximum number of ACLs per file/dir
  536. + *
  537. + * This value is limited by |UPCALL_BUF_SIZE| and |NFS4_OPAQUE_LIMIT_ATTR|,
  538. + * a bigger value requirs adjustments of both variables
  539. + */
  540. +#define NFS41_ACL_MAX_ACE_ENTRIES (128)
  541.  
  542.  #define NFS41_MAX_SERVER_CACHE  1024
  543.  #define NFS41_MAX_RPC_REQS      128
  544. @@ -62,6 +76,7 @@
  545.   * Size requirements:
  546.   * - This must fit at least twice (for rename) the maximum path length
  547.   * (see |NFS41_MAX_PATH_LEN| below) plus header
  548. + * - This must fit at least |NFS41_ACL_MAX_ACE_ENTRIES| ACE entries
  549.   */
  550.  #define UPCALL_BUF_SIZE     (16384)
  551.  
  552. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  553. index 0d1f0c5..8cb5aad 100644
  554. --- a/daemon/nfs41_ops.c
  555. +++ b/daemon/nfs41_ops.c
  556. @@ -557,7 +557,7 @@ int nfs41_open(
  557.  
  558.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  559.      getattr_args.attr_request = &attr_request;
  560. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  561. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  562.      getattr_res.info = info;
  563.  
  564.      if (current_fh_is_dir) {
  565. @@ -570,7 +570,7 @@ int nfs41_open(
  566.  
  567.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &pgetattr_res);
  568.      getattr_args.attr_request = &attr_request;
  569. -    pgetattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  570. +    pgetattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  571.      pgetattr_res.info = &dir_info;
  572.  
  573.      status = compound_encode_send_decode(session, &compound, try_recovery);
  574. @@ -658,14 +658,14 @@ int nfs41_create(
  575.  
  576.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  577.      getattr_args.attr_request = &attr_request;
  578. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  579. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  580.      getattr_res.info = info;
  581.  
  582.      compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res);
  583.  
  584.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &pgetattr_res);
  585.      getattr_args.attr_request = &attr_request;
  586. -    pgetattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  587. +    pgetattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  588.      pgetattr_res.info = &dir_info;
  589.  
  590.      status = compound_encode_send_decode(session, &compound, TRUE);
  591. @@ -734,7 +734,7 @@ int nfs41_close(
  592.  
  593.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  594.      getattr_args.attr_request = &attr_request;
  595. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  596. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  597.      getattr_res.info = &info;
  598.  
  599.      status = compound_encode_send_decode(session, &compound, TRUE);
  600. @@ -816,7 +816,7 @@ int nfs41_write(
  601.           * the attribute cache, so we do the GETATTR here */
  602.          compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  603.          getattr_args.attr_request = &attr_request;
  604. -        getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  605. +        getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  606.          getattr_res.info = pinfo;
  607.      }
  608.  
  609. @@ -959,7 +959,7 @@ int nfs41_commit(
  610.  
  611.          compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  612.          getattr_args.attr_request = &attr_request;
  613. -        getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  614. +        getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  615.          getattr_res.info = pinfo;
  616.      }
  617.  
  618. @@ -1181,7 +1181,7 @@ int nfs41_getattr(
  619.  
  620.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  621.      getattr_args.attr_request = attr_request;
  622. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  623. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  624.      getattr_res.info = info;
  625.  
  626.      status = compound_encode_send_decode(session, &compound, TRUE);
  627. @@ -1233,7 +1233,7 @@ int nfs41_superblock_getattr(
  628.  
  629.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  630.      getattr_args.attr_request = attr_request;
  631. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  632. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  633.      getattr_res.info = info;
  634.  
  635.      compound_add_op(&compound, OP_OPENATTR, &openattr_args, &openattr_res);
  636. @@ -1310,7 +1310,7 @@ int nfs41_remove(
  637.  
  638.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  639.      getattr_args.attr_request = &attr_request;
  640. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  641. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  642.      getattr_res.info = &info;
  643.  
  644.      status = compound_encode_send_decode(session, &compound, TRUE);
  645. @@ -1389,13 +1389,13 @@ int nfs41_rename(
  646.      
  647.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &dst_getattr_res);
  648.      getattr_args.attr_request = &attr_request;
  649. -    dst_getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  650. +    dst_getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  651.      dst_getattr_res.info = &dst_info;
  652.  
  653.      compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res);
  654.  
  655.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &src_getattr_res);
  656. -    src_getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  657. +    src_getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  658.      src_getattr_res.info = &src_info;
  659.  
  660.      status = compound_encode_send_decode(session, &compound, TRUE);
  661. @@ -1502,7 +1502,7 @@ int nfs41_setattr(
  662.  
  663.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  664.      getattr_args.attr_request = &attr_request;
  665. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  666. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  667.      getattr_res.info = info;
  668.  
  669.      status = compound_encode_send_decode(session, &compound, TRUE);
  670. @@ -1583,7 +1583,7 @@ int nfs41_link(
  671.      /* GETATTR(dst_dir) */
  672.      compound_add_op(&compound, OP_GETATTR, &getattr_args[0], &getattr_res[0]);
  673.      getattr_args[0].attr_request = &info.attrmask;
  674. -    getattr_res[0].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  675. +    getattr_res[0].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  676.      getattr_res[0].info = &info;
  677.  
  678.      /* LOOKUP(target) */
  679. @@ -1593,7 +1593,7 @@ int nfs41_link(
  680.      /* GETATTR(target) */
  681.      compound_add_op(&compound, OP_GETATTR, &getattr_args[1], &getattr_res[1]);
  682.      getattr_args[1].attr_request = &cinfo->attrmask;
  683. -    getattr_res[1].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  684. +    getattr_res[1].obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  685.      getattr_res[1].info = cinfo;
  686.  
  687.      /* GETFH(target) */
  688. @@ -1901,7 +1901,7 @@ enum nfsstat4 nfs41_fs_locations(
  689.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  690.      getattr_args.attr_request = &attr_request;
  691.      info.fs_locations = locations;
  692. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  693. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  694.      getattr_res.info = &info;
  695.  
  696.      status = compound_encode_send_decode(session, &compound, TRUE);
  697. @@ -2189,7 +2189,7 @@ enum nfsstat4 pnfs_rpc_layoutcommit(
  698.  
  699.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  700.      getattr_args.attr_request = &attr_request;
  701. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  702. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  703.      getattr_res.info = info;
  704.  
  705.      status = compound_encode_send_decode(session, &compound, TRUE);
  706. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  707. index 8501674..fe54f3a 100644
  708. --- a/daemon/nfs41_types.h
  709. +++ b/daemon/nfs41_types.h
  710. @@ -153,7 +153,7 @@ typedef struct __open_delegation4 {
  711.  typedef struct __fattr4 {
  712.      bitmap4         attrmask;
  713.      uint32_t        attr_vals_len;
  714. -    unsigned char   attr_vals[NFS4_OPAQUE_LIMIT];
  715. +    unsigned char   attr_vals[NFS4_OPAQUE_LIMIT_ATTR];
  716.  } fattr4;
  717.  
  718.  typedef struct __change_info4 {
  719. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  720. index 4b7eacb..4a4d8b1 100644
  721. --- a/daemon/nfs41_xdr.c
  722. +++ b/daemon/nfs41_xdr.c
  723. @@ -154,7 +154,10 @@ bool_t xdr_fattr4(
  724.      if (!xdr_bitmap4(xdr, &fattr->attrmask))
  725.          return FALSE;
  726.  
  727. -    return xdr_bytes(xdr, (char **)&attr_vals, &fattr->attr_vals_len, NFS4_OPAQUE_LIMIT);
  728. +    return xdr_bytes(xdr,
  729. +        (char **)&attr_vals,
  730. +        &fattr->attr_vals_len,
  731. +        NFS4_OPAQUE_LIMIT_ATTR);
  732.  }
  733.  
  734.  /* nfs41_fh */
  735. @@ -1375,7 +1378,7 @@ static bool_t encode_createattrs4(
  736.      fattr4 attrs;
  737.  
  738.      /* encode attribute values from createattrs->info into attrs.attr_vals */
  739. -    attrs.attr_vals_len = NFS4_OPAQUE_LIMIT;
  740. +    attrs.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  741.      if (!encode_file_attrs(&attrs, createattrs))
  742.          return FALSE;
  743.  
  744. @@ -2652,7 +2655,10 @@ static bool_t encode_file_attrs(
  745.      uint32_t i;
  746.      XDR localxdr;
  747.  
  748. -    xdrmem_create(&localxdr, (char *)attrs->attr_vals, NFS4_OPAQUE_LIMIT, XDR_ENCODE);
  749. +    xdrmem_create(&localxdr,
  750. +        (char *)attrs->attr_vals,
  751. +        NFS4_OPAQUE_LIMIT_ATTR,
  752. +        XDR_ENCODE);
  753.  
  754.      attrs->attr_vals_len = 0;
  755.      bitmap4_clear(&attrs->attrmask);
  756. @@ -2758,7 +2764,7 @@ static bool_t encode_op_setattr(
  757.          return FALSE;
  758.  
  759.      /* encode attribute values from args->info into attrs.attr_vals */
  760. -    attrs.attr_vals_len = NFS4_OPAQUE_LIMIT;
  761. +    attrs.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  762.      if (!encode_file_attrs(&attrs, args->info))
  763.          return FALSE;
  764.  
  765. diff --git a/daemon/nfs42_ops.c b/daemon/nfs42_ops.c
  766. index dc5a769..4c6a35c 100644
  767. --- a/daemon/nfs42_ops.c
  768. +++ b/daemon/nfs42_ops.c
  769. @@ -92,7 +92,7 @@ int nfs42_allocate(
  770.       */
  771.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  772.      getattr_args.attr_request = &attr_request;
  773. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  774. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  775.      getattr_res.info = pinfo;
  776.  
  777.      status = compound_encode_send_decode(session, &compound, TRUE);
  778. @@ -171,7 +171,7 @@ int nfs42_deallocate(
  779.       */
  780.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  781.      getattr_args.attr_request = &attr_request;
  782. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  783. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  784.      getattr_res.info = pinfo;
  785.  
  786.      status = compound_encode_send_decode(session, &compound, TRUE);
  787. @@ -374,7 +374,7 @@ int nfs42_clone(
  788.       */
  789.      compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
  790.      getattr_args.attr_request = &attr_request;
  791. -    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT;
  792. +    getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT_ATTR;
  793.      getattr_res.info = pinfo;
  794.  
  795.      status = compound_encode_send_decode(session, &compound, TRUE);
  796. diff --git a/daemon/sid.c b/daemon/sid.c
  797. index 9e0e356..afd2ee3 100644
  798. --- a/daemon/sid.c
  799. +++ b/daemon/sid.c
  800. @@ -226,7 +226,7 @@ bool unixgroup_sid2gid(PSID psid, gid_t *pgid)
  801.   * owner_group, other, nobody, world, ... } entries multiplied by two to
  802.   * make sure two concurrent icacls queries cannot trash the whole cache
  803.   */
  804. -#define SIDCACHE_SIZE 128
  805. +#define SIDCACHE_SIZE 384
  806.  #define SIDCACHE_TTL 600
  807.  
  808.  /* Safety/performance checks */
  809. --
  810. 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