- From dbf9bf0768dea2ec0fe5c7855693e9f43dfbcb10 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Thu, 11 Dec 2025 12:38:38 +0100
- Subject: [PATCH 1/2] sys: Fix "warning C6101: Returning uninitialized memory
- '*ret_sid'" in get_primarygroup_id()
- Fix Visual Studio compiler warning "sys\nfs41sys_util.c(225): warning
- C6101: Returning uninitialized memory '*ret_sid'. A successful path
- through the function does not set the named _Out_ parameter. Annotate
- this function with _Success_(return) if returning FALSE indicates failure"
- in get_primarygroup_id().
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_openclose.c | 4 ++--
- sys/nfs41sys_util.c | 9 +++++++--
- sys/nfs41sys_util.h | 4 +++-
- 3 files changed, 12 insertions(+), 5 deletions(-)
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index 0ab1cf6..3895c53 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -732,7 +732,7 @@ NTSTATUS nfs41_Create(
- nfs41_srvopen->initialised = TRUE;
- #ifdef WINBUG_NO_COLLAPSE_IF_PRIMARYGROUPS_DIFFER
- /* PrimaryGroup SID used for opening this NFS handle */
- - nfs41_srvopen->open_pg_sid = (PSID)nfs41_srvopen->open_pg_sidbuff;
- + nfs41_srvopen->open_pg_sid = (PSID)&nfs41_srvopen->open_pg_sidbuff[0];
- /*
- * Store PrimaryGroup SID used to create the |SRV_OPEN|
- @@ -1370,7 +1370,7 @@ NTSTATUS nfs41_ShouldTryToCollapseThisOpen(
- #else
- char pg_sidbuff[SID_BUF_SIZE] __attribute__((aligned(16)));
- #endif /* _MSC_BUILD */
- - PSID pg_sid = (PSID)pg_sidbuff;
- + PSID pg_sid = (PSID)&pg_sidbuff[0];
- (void)get_primarygroup_id(pg_sid);
- diff --git a/sys/nfs41sys_util.c b/sys/nfs41sys_util.c
- index f116aa5..6108a34 100644
- --- a/sys/nfs41sys_util.c
- +++ b/sys/nfs41sys_util.c
- @@ -222,12 +222,14 @@ PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
- return (PQUERY_ON_CREATE_ECP_CONTEXT)ecpContext;
- }
- -bool get_primarygroup_id(__out SID *restrict ret_sid)
- +_Success_(return == true) bool
- +get_primarygroup_id(
- + _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid)
- {
- PACCESS_TOKEN token = NULL;
- PVOID infoBuffer = NULL;
- NTSTATUS status;
- - bool retval = false;
- + bool retval;
- BOOLEAN copyOnOpen = FALSE;
- BOOLEAN effectiveOnly = FALSE;
- @@ -248,6 +250,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
- DbgPrint("get_primarygroup_id: "
- "SeQueryInformationToken(TokenPrimaryGroup) failed: 0x%lx\n",
- (long)status);
- + retval = false;
- goto out_cleanup_sequeryinfotok;
- }
- @@ -255,6 +258,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
- if ((primaryGroup == NULL) || (primaryGroup->PrimaryGroup == NULL)) {
- DbgP("get_primarygroup_id: "
- "primaryGroup or PrimaryGroup SID is NULL\n");
- + retval = false;
- goto out_cleanup_sequeryinfotok;
- }
- @@ -263,6 +267,7 @@ bool get_primarygroup_id(__out SID *restrict ret_sid)
- DbgP("get_primarygroup_id: "
- "SID length (%lu) invalid or too large for buffer (%u)\n",
- sidLength, (unsigned)SID_BUF_SIZE);
- + retval = false;
- goto out_cleanup_sequeryinfotok;
- }
- diff --git a/sys/nfs41sys_util.h b/sys/nfs41sys_util.h
- index f3a1aec..aa917f7 100644
- --- a/sys/nfs41sys_util.h
- +++ b/sys/nfs41sys_util.h
- @@ -69,6 +69,8 @@ NTSTATUS nfs41_UnmapLockedKernelPagesInNfsDaemonAddressSpace(
- __in PMDL MemoryDescriptorList);
- PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
- __in PIRP Irp);
- -bool get_primarygroup_id(__out SID *restrict ret_sid);
- +_Success_(return == true) bool
- +get_primarygroup_id(
- + _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid);
- #endif /* !_NFS41SYS_UTIL_H_ */
- --
- 2.51.0
- From 47349689e7757b1c16b9e752da2afff7d19efd3d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 11 Dec 2025 23:10:53 +0100
- Subject: [PATCH 2/2] daemon,sys: Implement support for ECP QUERY_ON_CREATE
- |QoCFileStatInformation|+|QoCFileLxInformation|
- Implement support for ECP QUERY_ON_CREATE |QoCFileStatInformation|
- and |QoCFileLxInformation|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/fileinfoutil.c | 4 ++
- sys/nfs41sys_openclose.c | 50 ++++++++++++++++++-
- sys/nfs41sys_util.c | 103 +++++++++++++++++++++++++++++++++++++++
- sys/nfs41sys_util.h | 11 +++++
- 4 files changed, 167 insertions(+), 1 deletion(-)
- diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
- index 0dca8ad..0ed40c8 100644
- --- a/daemon/fileinfoutil.c
- +++ b/daemon/fileinfoutil.c
- @@ -301,6 +301,10 @@ void nfs_to_stat_info(
- GENERIC_EXECUTE|GENERIC_WRITE|GENERIC_READ; /* FIXME */
- }
- +/*
- + * Note: Kernel module |qocec_file_stat_lx_information()| and userland
- + * daemon |nfs_to_stat_lx_info()| should be kept in sync!
- + */
- void nfs_to_stat_lx_info(
- IN void *daemon_context,
- IN const char *restrict name,
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index 3895c53..ba3c847 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -1269,6 +1269,28 @@ retry_on_link:
- !pVNetRootContext->read_only)
- nfs41_fcb->StandardInfo.DeletePending = TRUE;
- + if (qocec) {
- + if (qocec->RequestedClasses & QoCFileStatInformation) {
- + qocec_file_stat_information(&qocec->StatInformation, nfs41_fcb);
- +
- + qocec->ClassesProcessed |= QoCFileStatInformation;
- + }
- +
- +#ifdef NFS41_DRIVER_WSL_SUPPORT
- + if (qocec->RequestedClasses & QoCFileLxInformation) {
- + qocec_file_stat_lx_information(&qocec->LxInformation,
- + nfs41_fcb, pVNetRootContext);
- +
- + qocec->ClassesProcessed |= QoCFileLxInformation;
- + }
- +#endif /* NFS41_DRIVER_WSL_SUPPORT */
- +
- + qocec->ClassesWithErrors = 0;
- + qocec->ClassesWithNoData = 0;
- +
- + FsRtlAcknowledgeEcp(qocec);
- + }
- +
- RxContext->Create.ReturnedCreateInformation =
- map_disposition_to_create_retval(params->Disposition, entry->errno);
- @@ -1432,12 +1454,15 @@ NTSTATUS nfs41_CollapseOpen(
- #ifdef ENABLE_COLLAPSEOPEN
- NTSTATUS status;
- PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- + PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext =
- + NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- + PMRX_FCB Fcb = RxContext->pFcb;
- + PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(Fcb);
- FsRtlEnterFileSystem();
- /*
- * FIXME/ToDo:
- - * - Check whether ECP (Extended Create Parameters) must be handled
- * - Check whether Cygwin/SFU EA must be handled
- */
- @@ -1454,7 +1479,30 @@ NTSTATUS nfs41_CollapseOpen(
- if (status)
- goto out;
- + if (qocec) {
- + if (qocec->RequestedClasses & QoCFileStatInformation) {
- + qocec_file_stat_information(&qocec->StatInformation, nfs41_fcb);
- +
- + qocec->ClassesProcessed |= QoCFileStatInformation;
- + }
- +
- +#ifdef NFS41_DRIVER_WSL_SUPPORT
- + if (qocec->RequestedClasses & QoCFileLxInformation) {
- + qocec_file_stat_lx_information(&qocec->LxInformation,
- + nfs41_fcb, pVNetRootContext);
- +
- + qocec->ClassesProcessed |= QoCFileLxInformation;
- + }
- +#endif /* NFS41_DRIVER_WSL_SUPPORT */
- +
- + qocec->ClassesWithErrors = 0;
- + qocec->ClassesWithNoData = 0;
- +
- + FsRtlAcknowledgeEcp(qocec);
- + }
- +
- RxContext->pFobx->OffsetOfNextEaToReturn = 1; /* FIXME: Why ? */
- +
- status = STATUS_SUCCESS;
- out:
- diff --git a/sys/nfs41sys_util.c b/sys/nfs41sys_util.c
- index 6108a34..c6e95de 100644
- --- a/sys/nfs41sys_util.c
- +++ b/sys/nfs41sys_util.c
- @@ -285,3 +285,106 @@ out_cleanup_sequeryinfotok:
- return retval;
- }
- +
- +void qocec_file_stat_information(
- + OUT QUERY_ON_CREATE_FILE_STAT_INFORMATION *restrict qocfsi,
- + IN const NFS41_FCB *restrict nfs41_fcb)
- +{
- + DbgP("qocec_file_stat_information: "
- + "qocfsi=0x%p, nfs41_fcb=0x%p\n",
- + qocfsi, nfs41_fcb);
- +
- + qocfsi->FileId.QuadPart = nfs41_fcb->fileid;
- + qocfsi->CreationTime = nfs41_fcb->BasicInfo.CreationTime;
- + qocfsi->LastAccessTime = nfs41_fcb->BasicInfo.LastAccessTime;
- + qocfsi->LastWriteTime = nfs41_fcb->BasicInfo.LastWriteTime;
- + qocfsi->ChangeTime = nfs41_fcb->BasicInfo.ChangeTime;
- + qocfsi->AllocationSize = nfs41_fcb->StandardInfo.AllocationSize;
- + qocfsi->EndOfFile = nfs41_fcb->StandardInfo.EndOfFile;
- + qocfsi->FileAttributes = nfs41_fcb->BasicInfo.FileAttributes;
- + if (nfs41_fcb->BasicInfo.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
- + qocfsi->ReparseTag = IO_REPARSE_TAG_SYMLINK;
- + }
- + else {
- + qocfsi->ReparseTag = 0;
- + }
- + qocfsi->NumberOfLinks = nfs41_fcb->StandardInfo.NumberOfLinks;
- +}
- +
- +#ifdef NFS41_DRIVER_WSL_SUPPORT
- +/*
- + * Note: Kernel module |qocec_file_stat_lx_information()| and userland
- + * daemon |nfs_to_stat_lx_info()| should be kept in sync!
- + */
- +void qocec_file_stat_lx_information(
- + OUT QUERY_ON_CREATE_FILE_LX_INFORMATION *restrict qocflxi,
- + IN const NFS41_FCB *restrict nfs41_fcb,
- + IN const NFS41_V_NET_ROOT_EXTENSION *restrict pVNetRootContext)
- +{
- + ULONG fsattrs;
- +
- + DbgP("qocec_file_stat_lx_information: "
- + "qocflxi=0x%p, nfs41_fcb=0x%p, pVNetRootContext=0x%p\n",
- + qocflxi, nfs41_fcb, pVNetRootContext);
- +
- + qocflxi->EffectiveAccess =
- + GENERIC_EXECUTE|GENERIC_WRITE|GENERIC_READ; /* FIXME */
- + qocflxi->LxFlags =
- + LX_FILE_METADATA_HAS_UID |
- + LX_FILE_METADATA_HAS_GID |
- + LX_FILE_METADATA_HAS_MODE;
- +
- + qocflxi->LxUid = nfs41_fcb->owner_local_uid;
- + qocflxi->LxGid = nfs41_fcb->owner_group_local_gid;
- +
- + qocflxi->LxMode = 0UL;
- +
- +/* NFSv4 Mode bits from "daemon/nfs41_const.h" */
- +#define MODE4_SUID 0x800 /* set user id on execution */
- +#define MODE4_SGID 0x400 /* set group id on execution */
- +#define MODE4_SVTX 0x200 /* save text even after use */
- +#define MODE4_RUSR 0x100 /* read permission: owner */
- +#define MODE4_WUSR 0x080 /* write permission: owner */
- +#define MODE4_XUSR 0x040 /* execute permission: owner */
- +#define MODE4_RGRP 0x020 /* read permission: group */
- +#define MODE4_WGRP 0x010 /* write permission: group */
- +#define MODE4_XGRP 0x008 /* execute permission: group */
- +#define MODE4_ROTH 0x004 /* read permission: other */
- +#define MODE4_WOTH 0x002 /* write permission: other */
- +#define MODE4_XOTH 0x001 /* execute permission: other */
- +
- +/* FIXME: This should go into a new header in include/ */
- +#define LX_MODE_S_IFMT 0xF000 /* file type mask */
- +#define LX_MODE_S_IFREG 0x8000 /* regular */
- +#define LX_MODE_S_IFDIR 0x4000 /* directory */
- +#define LX_MODE_S_IFCHR 0x2000 /* character special */
- +#define LX_MODE_S_IFIFO 0x1000 /* pipe */
- +#define LX_MODE_S_IREAD 0x0100 /* read permission, owner */
- +#define LX_MODE_S_IWRITE 0x0080 /* write permission, owner */
- +#define LX_MODE_S_IEXEC 0x0040 /* execute/search permission, owner */
- +
- + /*
- + * Symlinks are handled via
- + * |QUERY_ON_CREATE_FILE_STAT_INFORMATION.ReparseTag|
- + */
- + if (nfs41_fcb->StandardInfo.Directory)
- + qocflxi->LxMode |= LX_MODE_S_IFDIR;
- + else
- + qocflxi->LxMode |= LX_MODE_S_IFREG;
- +
- + if (nfs41_fcb->mode & MODE4_RUSR)
- + qocflxi->LxMode |= LX_MODE_S_IREAD;
- + if (nfs41_fcb->mode & MODE4_WUSR)
- + qocflxi->LxMode |= LX_MODE_S_IWRITE;
- + if (nfs41_fcb->mode & MODE4_XUSR)
- + qocflxi->LxMode |= LX_MODE_S_IEXEC;
- +
- + fsattrs = pVNetRootContext->FsAttrs.FileSystemAttributes;
- + if (fsattrs & FILE_CASE_SENSITIVE_SEARCH)
- + qocflxi->LxMode |= LX_FILE_CASE_SENSITIVE_DIR;
- +
- + /* FIXME: We should support devices */
- + qocflxi->LxDeviceIdMajor = 0;
- + qocflxi->LxDeviceIdMinor = 0;
- +}
- +#endif /* NFS41_DRIVER_WSL_SUPPORT */
- diff --git a/sys/nfs41sys_util.h b/sys/nfs41sys_util.h
- index aa917f7..39f49de 100644
- --- a/sys/nfs41sys_util.h
- +++ b/sys/nfs41sys_util.h
- @@ -24,6 +24,8 @@
- #ifndef _NFS41SYS_UTIL_H_
- #define _NFS41SYS_UTIL_H_ 1
- +#include "nfs41_build_features.h"
- +
- #include <stdbool.h>
- static INLINE BOOL AnsiStrEq(
- @@ -72,5 +74,14 @@ PQUERY_ON_CREATE_ECP_CONTEXT get_queryoncreateecpcontext(
- _Success_(return == true) bool
- get_primarygroup_id(
- _Out_writes_bytes_(SID_BUF_SIZE) SID *restrict ret_sid);
- +void qocec_file_stat_information(
- + OUT QUERY_ON_CREATE_FILE_STAT_INFORMATION *restrict qocfsi,
- + IN const NFS41_FCB *restrict nfs41_fcb);
- +#ifdef NFS41_DRIVER_WSL_SUPPORT
- +void qocec_file_stat_lx_information(
- + OUT QUERY_ON_CREATE_FILE_LX_INFORMATION *restrict qocflxi,
- + IN const NFS41_FCB *restrict nfs41_fcb,
- + IN const NFS41_V_NET_ROOT_EXTENSION *restrict pVNetRootContext);
- +#endif /* NFS41_DRIVER_WSL_SUPPORT */
- #endif /* !_NFS41SYS_UTIL_H_ */
- --
- 2.51.0
msnfs41client: Patch msnfs41client_ecpqueryconcreate_misc_20251211_001.tar.bz2
Posted by Anonymous on Wed 17th Dec 2025 10:27
raw | new post
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.
rovema.kpaste.net RSS