pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patch msnfs41client_ecpqueryconcreate_misc_20251211_001.tar.bz2
Posted by Anonymous on Wed 17th Dec 2025 10:27
raw | new post

  1. From dbf9bf0768dea2ec0fe5c7855693e9f43dfbcb10 Mon Sep 17 00:00:00 2001
  2. From: Dan Shelton <dan.f.shelton@gmail.com>
  3. Date: Thu, 11 Dec 2025 12:38:38 +0100
  4. Subject: [PATCH 1/2] sys: Fix "warning C6101: Returning uninitialized memory
  5.  '*ret_sid'" in get_primarygroup_id()
  6.  
  7. Fix Visual Studio compiler warning "sys\nfs41sys_util.c(225): warning
  8. C6101: Returning uninitialized memory '*ret_sid'.  A successful path
  9. through the function does not set the named _Out_ parameter. Annotate
  10. this function with _Success_(return) if returning FALSE indicates failure"
  11. in get_primarygroup_id().
  12.  
  13. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  14. ---
  15. sys/nfs41sys_openclose.c | 4 ++--
  16.  sys/nfs41sys_util.c      | 9 +++++++--
  17.  sys/nfs41sys_util.h      | 4 +++-
  18.  3 files changed, 12 insertions(+), 5 deletions(-)
  19.  
  20. diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
  21. index 0ab1cf6..3895c53 100644
  22. --- a/sys/nfs41sys_openclose.c
  23. +++ b/sys/nfs41sys_openclose.c
  24. @@ -732,7 +732,7 @@ NTSTATUS nfs41_Create(
  25.          nfs41_srvopen->initialised = TRUE;
  26.  #ifdef WINBUG_NO_COLLAPSE_IF_PRIMARYGROUPS_DIFFER
  27.          /* PrimaryGroup SID used for opening this NFS handle */
  28. -        nfs41_srvopen->open_pg_sid = (PSID)nfs41_srvopen->open_pg_sidbuff;
  29. +        nfs41_srvopen->open_pg_sid = (PSID)&nfs41_srvopen->open_pg_sidbuff[0];
  30.  
  31.          /*
  32.           * Store PrimaryGroup SID used to create the |SRV_OPEN|
  33. @@ -1370,7 +1370,7 @@ NTSTATUS nfs41_ShouldTryToCollapseThisOpen(
  34.  #else
  35.      char pg_sidbuff[SID_BUF_SIZE] __attribute__((aligned(16)));
  36.  #endif /* _MSC_BUILD */
  37. -    PSID pg_sid = (PSID)pg_sidbuff;
  38. +    PSID pg_sid = (PSID)&pg_sidbuff[0];
  39.  
  40.      (void)get_primarygroup_id(pg_sid);
  41.  
  42. diff --git a/sys/nfs41sys_util.c b/sys/nfs41sys_util.c
  43. index f116aa5..6108a34 100644
  44. --- a/sys/nfs41sys_util.c
  45. +++ b/sys/nfs41sys_util.c
  46. @@ -222,12 +222,14 @@ PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
  47.      return (PQUERY_ON_CREATE_ECP_CONTEXT)ecpContext;
  48.  }
  49.  
  50. -bool get_primarygroup_id(__out SID *restrict ret_sid)
  51. +_Success_(return == true) bool
  52. +get_primarygroup_id(
  53. +    _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid)
  54.  {
  55.      PACCESS_TOKEN token = NULL;
  56.      PVOID infoBuffer = NULL;
  57.      NTSTATUS status;
  58. -    bool retval = false;
  59. +    bool retval;
  60.  
  61.      BOOLEAN copyOnOpen = FALSE;
  62.      BOOLEAN effectiveOnly = FALSE;
  63. @@ -248,6 +250,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
  64.          DbgPrint("get_primarygroup_id: "
  65.              "SeQueryInformationToken(TokenPrimaryGroup) failed: 0x%lx\n",
  66.              (long)status);
  67. +        retval = false;
  68.          goto out_cleanup_sequeryinfotok;
  69.      }
  70.  
  71. @@ -255,6 +258,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
  72.      if ((primaryGroup == NULL) || (primaryGroup->PrimaryGroup == NULL)) {
  73.          DbgP("get_primarygroup_id: "
  74.              "primaryGroup or PrimaryGroup SID is NULL\n");
  75. +        retval = false;
  76.          goto out_cleanup_sequeryinfotok;
  77.      }
  78.  
  79. @@ -263,6 +267,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
  80.          DbgP("get_primarygroup_id: "
  81.              "SID length (%lu) invalid or too large for buffer (%u)\n",
  82.              sidLength, (unsigned)SID_BUF_SIZE);
  83. +        retval = false;
  84.          goto out_cleanup_sequeryinfotok;
  85.      }
  86.  
  87. diff --git a/sys/nfs41sys_util.h b/sys/nfs41sys_util.h
  88. index f3a1aec..aa917f7 100644
  89. --- a/sys/nfs41sys_util.h
  90. +++ b/sys/nfs41sys_util.h
  91. @@ -69,6 +69,8 @@ NTSTATUS nfs41_UnmapLockedKernelPagesInNfsDaemonAddressSpace(
  92.      __in PMDL  MemoryDescriptorList);
  93.  PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
  94.      __in PIRP Irp);
  95. -bool get_primarygroup_id(__out SID *restrict ret_sid);
  96. +_Success_(return == true) bool
  97. +get_primarygroup_id(
  98. +    _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid);
  99.  
  100.  #endif /* !_NFS41SYS_UTIL_H_ */
  101. --
  102. 2.51.0
  103.  
  104. From 47349689e7757b1c16b9e752da2afff7d19efd3d Mon Sep 17 00:00:00 2001
  105. From: Roland Mainz <roland.mainz@nrubsig.org>
  106. Date: Thu, 11 Dec 2025 23:10:53 +0100
  107. Subject: [PATCH 2/2] daemon,sys: Implement support for ECP QUERY_ON_CREATE
  108.  |QoCFileStatInformation|+|QoCFileLxInformation|
  109.  
  110. Implement support for ECP QUERY_ON_CREATE |QoCFileStatInformation|
  111. and |QoCFileLxInformation|.
  112.  
  113. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  114. ---
  115. daemon/fileinfoutil.c    |   4 ++
  116.  sys/nfs41sys_openclose.c |  50 ++++++++++++++++++-
  117.  sys/nfs41sys_util.c      | 103 +++++++++++++++++++++++++++++++++++++++
  118.  sys/nfs41sys_util.h      |  11 +++++
  119.  4 files changed, 167 insertions(+), 1 deletion(-)
  120.  
  121. diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
  122. index 0dca8ad..0ed40c8 100644
  123. --- a/daemon/fileinfoutil.c
  124. +++ b/daemon/fileinfoutil.c
  125. @@ -301,6 +301,10 @@ void nfs_to_stat_info(
  126.          GENERIC_EXECUTE|GENERIC_WRITE|GENERIC_READ; /* FIXME */
  127.  }
  128.  
  129. +/*
  130. + * Note: Kernel module |qocec_file_stat_lx_information()| and userland
  131. + * daemon |nfs_to_stat_lx_info()| should be kept in sync!
  132. + */
  133.  void nfs_to_stat_lx_info(
  134.      IN void *daemon_context,
  135.      IN const char *restrict name,
  136. diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
  137. index 3895c53..ba3c847 100644
  138. --- a/sys/nfs41sys_openclose.c
  139. +++ b/sys/nfs41sys_openclose.c
  140. @@ -1269,6 +1269,28 @@ retry_on_link:
  141.              !pVNetRootContext->read_only)
  142.          nfs41_fcb->StandardInfo.DeletePending = TRUE;
  143.  
  144. +    if (qocec) {
  145. +        if (qocec->RequestedClasses & QoCFileStatInformation) {
  146. +            qocec_file_stat_information(&qocec->StatInformation, nfs41_fcb);
  147. +
  148. +            qocec->ClassesProcessed |= QoCFileStatInformation;
  149. +        }
  150. +
  151. +#ifdef NFS41_DRIVER_WSL_SUPPORT
  152. +        if (qocec->RequestedClasses & QoCFileLxInformation) {
  153. +            qocec_file_stat_lx_information(&qocec->LxInformation,
  154. +                nfs41_fcb, pVNetRootContext);
  155. +
  156. +            qocec->ClassesProcessed |= QoCFileLxInformation;
  157. +        }
  158. +#endif /* NFS41_DRIVER_WSL_SUPPORT */
  159. +
  160. +        qocec->ClassesWithErrors = 0;
  161. +        qocec->ClassesWithNoData = 0;
  162. +
  163. +        FsRtlAcknowledgeEcp(qocec);
  164. +    }
  165. +
  166.      RxContext->Create.ReturnedCreateInformation =
  167.          map_disposition_to_create_retval(params->Disposition, entry->errno);
  168.  
  169. @@ -1432,12 +1454,15 @@ NTSTATUS nfs41_CollapseOpen(
  170.  #ifdef ENABLE_COLLAPSEOPEN
  171.      NTSTATUS status;
  172.      PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
  173. +    PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext =
  174. +        NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
  175. +    PMRX_FCB Fcb = RxContext->pFcb;
  176. +    PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(Fcb);
  177.  
  178.      FsRtlEnterFileSystem();
  179.  
  180.      /*
  181.       * FIXME/ToDo:
  182. -     * - Check whether ECP (Extended Create Parameters) must be handled
  183.       * - Check whether Cygwin/SFU EA must be handled
  184.       */
  185.  
  186. @@ -1454,7 +1479,30 @@ NTSTATUS nfs41_CollapseOpen(
  187.      if (status)
  188.          goto out;
  189.  
  190. +    if (qocec) {
  191. +        if (qocec->RequestedClasses & QoCFileStatInformation) {
  192. +            qocec_file_stat_information(&qocec->StatInformation, nfs41_fcb);
  193. +
  194. +            qocec->ClassesProcessed |= QoCFileStatInformation;
  195. +        }
  196. +
  197. +#ifdef NFS41_DRIVER_WSL_SUPPORT
  198. +        if (qocec->RequestedClasses & QoCFileLxInformation) {
  199. +            qocec_file_stat_lx_information(&qocec->LxInformation,
  200. +                nfs41_fcb, pVNetRootContext);
  201. +
  202. +            qocec->ClassesProcessed |= QoCFileLxInformation;
  203. +        }
  204. +#endif /* NFS41_DRIVER_WSL_SUPPORT */
  205. +
  206. +        qocec->ClassesWithErrors = 0;
  207. +        qocec->ClassesWithNoData = 0;
  208. +
  209. +        FsRtlAcknowledgeEcp(qocec);
  210. +    }
  211. +
  212.      RxContext->pFobx->OffsetOfNextEaToReturn = 1; /* FIXME: Why ? */
  213. +
  214.      status = STATUS_SUCCESS;
  215.  
  216.  out:
  217. diff --git a/sys/nfs41sys_util.c b/sys/nfs41sys_util.c
  218. index 6108a34..c6e95de 100644
  219. --- a/sys/nfs41sys_util.c
  220. +++ b/sys/nfs41sys_util.c
  221. @@ -285,3 +285,106 @@ out_cleanup_sequeryinfotok:
  222.  
  223.      return retval;
  224.  }
  225. +
  226. +void qocec_file_stat_information(
  227. +    OUT QUERY_ON_CREATE_FILE_STAT_INFORMATION *restrict qocfsi,
  228. +    IN const NFS41_FCB *restrict nfs41_fcb)
  229. +{
  230. +    DbgP("qocec_file_stat_information: "
  231. +        "qocfsi=0x%p, nfs41_fcb=0x%p\n",
  232. +        qocfsi, nfs41_fcb);
  233. +
  234. +    qocfsi->FileId.QuadPart = nfs41_fcb->fileid;
  235. +    qocfsi->CreationTime    = nfs41_fcb->BasicInfo.CreationTime;
  236. +    qocfsi->LastAccessTime  = nfs41_fcb->BasicInfo.LastAccessTime;
  237. +    qocfsi->LastWriteTime   = nfs41_fcb->BasicInfo.LastWriteTime;
  238. +    qocfsi->ChangeTime      = nfs41_fcb->BasicInfo.ChangeTime;
  239. +    qocfsi->AllocationSize  = nfs41_fcb->StandardInfo.AllocationSize;
  240. +    qocfsi->EndOfFile       = nfs41_fcb->StandardInfo.EndOfFile;
  241. +    qocfsi->FileAttributes  = nfs41_fcb->BasicInfo.FileAttributes;
  242. +    if (nfs41_fcb->BasicInfo.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
  243. +        qocfsi->ReparseTag = IO_REPARSE_TAG_SYMLINK;
  244. +    }
  245. +    else {
  246. +        qocfsi->ReparseTag = 0;
  247. +    }
  248. +    qocfsi->NumberOfLinks   = nfs41_fcb->StandardInfo.NumberOfLinks;
  249. +}
  250. +
  251. +#ifdef NFS41_DRIVER_WSL_SUPPORT
  252. +/*
  253. + * Note: Kernel module |qocec_file_stat_lx_information()| and userland
  254. + * daemon |nfs_to_stat_lx_info()| should be kept in sync!
  255. + */
  256. +void qocec_file_stat_lx_information(
  257. +    OUT QUERY_ON_CREATE_FILE_LX_INFORMATION *restrict qocflxi,
  258. +    IN const NFS41_FCB *restrict nfs41_fcb,
  259. +    IN const NFS41_V_NET_ROOT_EXTENSION *restrict pVNetRootContext)
  260. +{
  261. +    ULONG fsattrs;
  262. +
  263. +    DbgP("qocec_file_stat_lx_information: "
  264. +        "qocflxi=0x%p, nfs41_fcb=0x%p, pVNetRootContext=0x%p\n",
  265. +        qocflxi, nfs41_fcb, pVNetRootContext);
  266. +
  267. +    qocflxi->EffectiveAccess =
  268. +        GENERIC_EXECUTE|GENERIC_WRITE|GENERIC_READ; /* FIXME */
  269. +    qocflxi->LxFlags =
  270. +        LX_FILE_METADATA_HAS_UID |
  271. +        LX_FILE_METADATA_HAS_GID |
  272. +        LX_FILE_METADATA_HAS_MODE;
  273. +
  274. +    qocflxi->LxUid = nfs41_fcb->owner_local_uid;
  275. +    qocflxi->LxGid = nfs41_fcb->owner_group_local_gid;
  276. +
  277. +    qocflxi->LxMode = 0UL;
  278. +
  279. +/* NFSv4 Mode bits from "daemon/nfs41_const.h" */
  280. +#define MODE4_SUID 0x800    /* set user id on execution     */
  281. +#define MODE4_SGID 0x400    /* set group id on execution    */
  282. +#define MODE4_SVTX 0x200    /* save text even after use     */
  283. +#define MODE4_RUSR 0x100    /* read permission: owner       */
  284. +#define MODE4_WUSR 0x080    /* write permission: owner      */
  285. +#define MODE4_XUSR 0x040    /* execute permission: owner    */
  286. +#define MODE4_RGRP 0x020    /* read permission: group       */
  287. +#define MODE4_WGRP 0x010    /* write permission: group      */
  288. +#define MODE4_XGRP 0x008    /* execute permission: group    */
  289. +#define MODE4_ROTH 0x004    /* read permission: other       */
  290. +#define MODE4_WOTH 0x002    /* write permission: other      */
  291. +#define MODE4_XOTH 0x001    /* execute permission: other    */
  292. +
  293. +/* FIXME: This should go into a new header in include/ */
  294. +#define LX_MODE_S_IFMT      0xF000 /* file type mask */
  295. +#define LX_MODE_S_IFREG     0x8000 /* regular */
  296. +#define LX_MODE_S_IFDIR     0x4000 /* directory */
  297. +#define LX_MODE_S_IFCHR     0x2000 /* character special */
  298. +#define LX_MODE_S_IFIFO     0x1000 /* pipe */
  299. +#define LX_MODE_S_IREAD     0x0100 /* read permission, owner */
  300. +#define LX_MODE_S_IWRITE    0x0080 /* write permission, owner */
  301. +#define LX_MODE_S_IEXEC     0x0040 /* execute/search permission, owner */
  302. +
  303. +    /*
  304. +     * Symlinks are handled via
  305. +     * |QUERY_ON_CREATE_FILE_STAT_INFORMATION.ReparseTag|
  306. +     */
  307. +    if (nfs41_fcb->StandardInfo.Directory)
  308. +        qocflxi->LxMode |= LX_MODE_S_IFDIR;
  309. +    else
  310. +        qocflxi->LxMode |= LX_MODE_S_IFREG;
  311. +
  312. +    if (nfs41_fcb->mode & MODE4_RUSR)
  313. +        qocflxi->LxMode |= LX_MODE_S_IREAD;
  314. +    if (nfs41_fcb->mode & MODE4_WUSR)
  315. +        qocflxi->LxMode |= LX_MODE_S_IWRITE;
  316. +    if (nfs41_fcb->mode & MODE4_XUSR)
  317. +        qocflxi->LxMode |= LX_MODE_S_IEXEC;
  318. +
  319. +    fsattrs = pVNetRootContext->FsAttrs.FileSystemAttributes;
  320. +    if (fsattrs & FILE_CASE_SENSITIVE_SEARCH)
  321. +        qocflxi->LxMode |= LX_FILE_CASE_SENSITIVE_DIR;
  322. +
  323. +    /* FIXME: We should support devices */
  324. +    qocflxi->LxDeviceIdMajor = 0;
  325. +    qocflxi->LxDeviceIdMinor = 0;
  326. +}
  327. +#endif /* NFS41_DRIVER_WSL_SUPPORT */
  328. diff --git a/sys/nfs41sys_util.h b/sys/nfs41sys_util.h
  329. index aa917f7..39f49de 100644
  330. --- a/sys/nfs41sys_util.h
  331. +++ b/sys/nfs41sys_util.h
  332. @@ -24,6 +24,8 @@
  333.  #ifndef _NFS41SYS_UTIL_H_
  334.  #define _NFS41SYS_UTIL_H_ 1
  335.  
  336. +#include "nfs41_build_features.h"
  337. +
  338.  #include <stdbool.h>
  339.  
  340.  static INLINE BOOL AnsiStrEq(
  341. @@ -72,5 +74,14 @@ PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
  342.  _Success_(return == true) bool
  343.  get_primarygroup_id(
  344.      _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid);
  345. +void qocec_file_stat_information(
  346. +    OUT QUERY_ON_CREATE_FILE_STAT_INFORMATION *restrict qocfsi,
  347. +    IN const NFS41_FCB *restrict nfs41_fcb);
  348. +#ifdef NFS41_DRIVER_WSL_SUPPORT
  349. +void qocec_file_stat_lx_information(
  350. +    OUT QUERY_ON_CREATE_FILE_LX_INFORMATION *restrict qocflxi,
  351. +    IN const NFS41_FCB *restrict nfs41_fcb,
  352. +    IN const NFS41_V_NET_ROOT_EXTENSION *restrict pVNetRootContext);
  353. +#endif /* NFS41_DRIVER_WSL_SUPPORT */
  354.  
  355.  #endif /* !_NFS41SYS_UTIL_H_ */
  356. --
  357. 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