- From 2c6aec09e59bde58ef9d652d4b838b7e68dd56e7 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 11:53:53 +0200
- Subject: [PATCH 1/6] sys: Handle
- |LowIoContext->ParamsFor.IoCtl.pInputBuffer|&co as |const|+use |restrict|
- Handle |LowIoContext->ParamsFor.IoCtl.pInputBuffer|&co as |const|+use
- |restrict|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_acl.c | 2 +-
- sys/nfs41sys_dir.c | 2 +-
- sys/nfs41sys_driver.c | 8 +++---
- sys/nfs41sys_driver.h | 28 ++++++++++----------
- sys/nfs41sys_ea.c | 2 +-
- sys/nfs41sys_fileinfo.c | 4 +--
- sys/nfs41sys_fsctl.c | 42 ++++++++++++++---------------
- sys/nfs41sys_mount.c | 7 ++---
- sys/nfs41sys_openclose.c | 2 +-
- sys/nfs41sys_readwrite.c | 2 +-
- sys/nfs41sys_reparse.c | 6 +++--
- sys/nfs41sys_symlink.c | 8 +++---
- sys/nfs41sys_updowncall.c | 56 +++++++++++++++++++--------------------
- sys/nfs41sys_volinfo.c | 2 +-
- 14 files changed, 88 insertions(+), 83 deletions(-)
- diff --git a/sys/nfs41sys_acl.c b/sys/nfs41sys_acl.c
- index 66ce93f..d2c0a6e 100644
- --- a/sys/nfs41sys_acl.c
- +++ b/sys/nfs41sys_acl.c
- @@ -137,7 +137,7 @@ out:
- NTSTATUS unmarshal_nfs41_getacl(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- DWORD buf_len;
- diff --git a/sys/nfs41sys_dir.c b/sys/nfs41sys_dir.c
- index e86a231..75b2820 100644
- --- a/sys/nfs41sys_dir.c
- +++ b/sys/nfs41sys_dir.c
- @@ -137,7 +137,7 @@ out:
- NTSTATUS unmarshal_nfs41_dirquery(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- ULONG buf_len;
- diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
- index 3bf52cc..e9e4486 100644
- --- a/sys/nfs41sys_driver.c
- +++ b/sys/nfs41sys_driver.c
- @@ -277,12 +277,12 @@ NTSTATUS nfs41_invalidate_cache(
- IN PRX_CONTEXT RxContext)
- {
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- - unsigned char *buf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const unsigned char *inbuf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- ULONG flag = DISABLE_CACHING;
- PMRX_SRV_OPEN srv_open;
- NTSTATUS status;
- - RtlCopyMemory(&srv_open, buf, sizeof(HANDLE));
- + RtlCopyMemory(&srv_open, inbuf, sizeof(HANDLE));
- #ifdef DEBUG_INVALIDATE_CACHE
- DbgP("nfs41_invalidate_cache: received srv_open=0x%p '%wZ'\n",
- srv_open, srv_open->pAlreadyPrefixedName);
- @@ -454,7 +454,7 @@ NTSTATUS nfs41_DevFcbXXXControlFile(
- PLOWIO_CONTEXT io_ctx = &RxContext->LowIoContext;
- ULONG fsop = io_ctx->ParamsFor.FsCtl.FsControlCode, state;
- ULONG in_len = io_ctx->ParamsFor.IoCtl.InputBufferLength;
- - DWORD *buf = io_ctx->ParamsFor.IoCtl.pInputBuffer;
- + const DWORD *inbuf = io_ctx->ParamsFor.IoCtl.pInputBuffer;
- PNFS41_DEVICE_EXTENSION DevExt =
- NFS41GetDeviceExtension(RxContext->RxDeviceObject);
- DWORD nfs41d_version = 0;
- @@ -521,7 +521,7 @@ NTSTATUS nfs41_DevFcbXXXControlFile(
- case IOCTL_NFS41_START:
- print_driver_state(nfs41_start_state);
- if (in_len >= sizeof(DWORD)) {
- - RtlCopyMemory(&nfs41d_version, buf, sizeof(DWORD));
- + RtlCopyMemory(&nfs41d_version, inbuf, sizeof(DWORD));
- DbgP("NFS41 Daemon sent start request with version %d\n",
- nfs41d_version);
- DbgP("Currently used NFS41 Daemon version is %d\n",
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index fa019f4..92c21cc 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -616,7 +616,7 @@ NTSTATUS marshal_nfs41_setacl(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_getacl(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_QuerySecurityInformation(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_SetSecurityInformation(
- @@ -630,7 +630,7 @@ NTSTATUS marshal_nfs41_dirquery(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_dirquery(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- void print_debug_filedirquery_header(
- PRX_CONTEXT RxContext);
- NTSTATUS check_nfs41_dirquery_args(
- @@ -671,7 +671,7 @@ NTSTATUS marshal_nfs41_eaget(
- ULONG *len);
- void unmarshal_nfs41_eaget(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_SetEaInformation(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_QueryEaInformation(
- @@ -687,7 +687,7 @@ NTSTATUS marshal_nfs41_queryallocatedranges(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_queryallocatedranges(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS marshal_nfs41_setzerodata(
- nfs41_updowncall_entry *entry,
- unsigned char *buf,
- @@ -695,7 +695,7 @@ NTSTATUS marshal_nfs41_setzerodata(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_setzerodata(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS marshal_nfs41_duplicatedata(
- nfs41_updowncall_entry *entry,
- unsigned char *buf,
- @@ -703,7 +703,7 @@ NTSTATUS marshal_nfs41_duplicatedata(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_duplicatedata(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- void nfs41_remove_offloadcontext_for_fobx(
- IN PMRX_FOBX pFobx);
- @@ -747,7 +747,7 @@ NTSTATUS marshal_nfs41_unmount(
- ULONG *len);
- void unmarshal_nfs41_mount(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_unmount(
- HANDLE session,
- DWORD version,
- @@ -808,7 +808,7 @@ NTSTATUS marshal_nfs41_close(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_open(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_Create(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_CollapseOpen(
- @@ -826,7 +826,7 @@ NTSTATUS marshal_nfs41_rw(
- ULONG *len);
- NTSTATUS unmarshal_nfs41_rw(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_Read(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_Write(
- @@ -844,7 +844,7 @@ NTSTATUS marshal_nfs41_symlink(
- ULONG *len);
- void unmarshal_nfs41_symlink(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_SetSymlinkReparsePoint(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_GetSymlinkReparsePoint(
- @@ -868,7 +868,7 @@ void unmarshal_nfs41_attrget(
- nfs41_updowncall_entry *cur,
- PVOID attr_value,
- ULONG *attr_len,
- - unsigned char **buf,
- + const unsigned char *restrict *restrict buf,
- BOOL copy_partial);
- NTSTATUS nfs41_UpcallCreate(
- IN DWORD opcode,
- @@ -903,10 +903,10 @@ NTSTATUS marshal_nfs41_fileset(
- void unmarshal_nfs41_setattr(
- nfs41_updowncall_entry *cur,
- PULONGLONG dest_buf,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- void unmarshal_nfs41_getattr(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_QueryFileInformation(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_SetFileInformation(
- @@ -922,7 +922,7 @@ NTSTATUS marshal_nfs41_volume(
- ULONG *len);
- void unmarshal_nfs41_volume(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf);
- + const unsigned char *restrict *restrict buf);
- NTSTATUS nfs41_QueryVolumeInformation(
- IN OUT PRX_CONTEXT RxContext);
- diff --git a/sys/nfs41sys_ea.c b/sys/nfs41sys_ea.c
- index bb7845d..53b0790 100644
- --- a/sys/nfs41sys_ea.c
- +++ b/sys/nfs41sys_ea.c
- @@ -159,7 +159,7 @@ out:
- void unmarshal_nfs41_eaget(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- RtlCopyMemory(&cur->u.QueryEa.Overflow, *buf, sizeof(ULONG));
- *buf += sizeof(ULONG);
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index b4cd89f..bc84e30 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -141,7 +141,7 @@ out:
- void unmarshal_nfs41_setattr(
- nfs41_updowncall_entry *cur,
- PULONGLONG dest_buf,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- RtlCopyMemory(dest_buf, *buf, sizeof(ULONGLONG));
- #ifdef DEBUG_MARSHAL_DETAIL
- @@ -151,7 +151,7 @@ void unmarshal_nfs41_setattr(
- void unmarshal_nfs41_getattr(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf, FALSE);
- RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 8f25517..4a5d3f6 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -76,8 +76,8 @@ NTSTATUS check_nfs41_queryallocatedranges_args(
- XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- const USHORT HeaderLen = sizeof(FILE_ALLOCATED_RANGE_BUFFER);
- - __notnull PFILE_ALLOCATED_RANGE_BUFFER in_range_buffer =
- - (PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pInputBuffer;
- + __notnull const PFILE_ALLOCATED_RANGE_BUFFER in_range_buffer =
- + (const PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pInputBuffer;
- if (FsCtl->pInputBuffer == NULL) {
- status = STATUS_INVALID_USER_BUFFER;
- @@ -128,8 +128,8 @@ NTSTATUS nfs41_QueryAllocatedRanges(
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PFILE_ALLOCATED_RANGE_BUFFER in_range_buffer =
- - (PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pInputBuffer;
- + __notnull const PFILE_ALLOCATED_RANGE_BUFFER in_range_buffer =
- + (const PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pInputBuffer;
- __notnull PFILE_ALLOCATED_RANGE_BUFFER out_range_buffer =
- (PFILE_ALLOCATED_RANGE_BUFFER)FsCtl->pOutputBuffer;
- ULONG out_range_buffer_len = FsCtl->OutputBufferLength;
- @@ -307,7 +307,7 @@ out:
- NTSTATUS unmarshal_nfs41_queryallocatedranges(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- @@ -350,8 +350,8 @@ NTSTATUS nfs41_SetSparse(
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PFILE_SET_SPARSE_BUFFER set_parse_buffer =
- - (PFILE_SET_SPARSE_BUFFER)FsCtl->pInputBuffer;
- + __notnull const PFILE_SET_SPARSE_BUFFER set_parse_buffer =
- + (const PFILE_SET_SPARSE_BUFFER)FsCtl->pInputBuffer;
- DbgEn();
- @@ -448,8 +448,8 @@ NTSTATUS nfs41_SetZeroData(
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PFILE_ZERO_DATA_INFORMATION setzerodatabuffer =
- - (PFILE_ZERO_DATA_INFORMATION)FsCtl->pInputBuffer;
- + __notnull const PFILE_ZERO_DATA_INFORMATION setzerodatabuffer =
- + (const PFILE_ZERO_DATA_INFORMATION)FsCtl->pInputBuffer;
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- DbgEn();
- @@ -567,7 +567,7 @@ out:
- NTSTATUS unmarshal_nfs41_setzerodata(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- @@ -662,8 +662,8 @@ NTSTATUS nfs41_DuplicateData(
- goto out;
- }
- - PDUPLICATE_EXTENTS_DATA32 ded32bit =
- - (PDUPLICATE_EXTENTS_DATA32)FsCtl->pInputBuffer;
- + const PDUPLICATE_EXTENTS_DATA32 ded32bit =
- + (const PDUPLICATE_EXTENTS_DATA32)FsCtl->pInputBuffer;
- dd.handle = (HANDLE)ded32bit->FileHandle;
- dd.srcfileoffset = ded32bit->SourceFileOffset.QuadPart;
- @@ -681,8 +681,8 @@ NTSTATUS nfs41_DuplicateData(
- goto out;
- }
- - PDUPLICATE_EXTENTS_DATA ded =
- - (PDUPLICATE_EXTENTS_DATA)FsCtl->pInputBuffer;
- + const PDUPLICATE_EXTENTS_DATA ded =
- + (const PDUPLICATE_EXTENTS_DATA)FsCtl->pInputBuffer;
- dd.handle = ded->FileHandle;
- dd.srcfileoffset = ded->SourceFileOffset.QuadPart;
- @@ -884,7 +884,7 @@ out:
- NTSTATUS unmarshal_nfs41_duplicatedata(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- @@ -1025,7 +1025,7 @@ NTSTATUS nfs41_OffloadRead(
- IN OUT PRX_CONTEXT RxContext)
- {
- NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;
- - __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- + __notnull const XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- @@ -1062,8 +1062,8 @@ NTSTATUS nfs41_OffloadRead(
- goto out;
- }
- - PFSCTL_OFFLOAD_READ_INPUT ori =
- - (PFSCTL_OFFLOAD_READ_INPUT)FsCtl->pInputBuffer;
- + const PFSCTL_OFFLOAD_READ_INPUT ori =
- + (const PFSCTL_OFFLOAD_READ_INPUT)FsCtl->pInputBuffer;
- PFSCTL_OFFLOAD_READ_OUTPUT oro =
- (PFSCTL_OFFLOAD_READ_OUTPUT)FsCtl->pOutputBuffer;
- @@ -1158,7 +1158,7 @@ NTSTATUS nfs41_OffloadWrite(
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- __notnull PNFS41_NETROOT_EXTENSION pNetRootContext =
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- - __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- + __notnull const XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- offloadcontext_entry *src_oce = NULL;
- @@ -1199,8 +1199,8 @@ NTSTATUS nfs41_OffloadWrite(
- goto out;
- }
- - PFSCTL_OFFLOAD_WRITE_INPUT owi =
- - (PFSCTL_OFFLOAD_WRITE_INPUT)FsCtl->pInputBuffer;
- + const PFSCTL_OFFLOAD_WRITE_INPUT owi =
- + (const PFSCTL_OFFLOAD_WRITE_INPUT)FsCtl->pInputBuffer;
- PFSCTL_OFFLOAD_WRITE_OUTPUT owo =
- (PFSCTL_OFFLOAD_WRITE_OUTPUT)FsCtl->pOutputBuffer;
- diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
- index ac5e8d6..c480c22 100644
- --- a/sys/nfs41sys_mount.c
- +++ b/sys/nfs41sys_mount.c
- @@ -176,7 +176,7 @@ NTSTATUS marshal_nfs41_unmount(
- void unmarshal_nfs41_mount(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- RtlCopyMemory(&cur->session, *buf, sizeof(HANDLE));
- *buf += sizeof(HANDLE);
- @@ -1653,7 +1653,8 @@ NTSTATUS nfs41_CreateConnection(
- NTSTATUS status = STATUS_SUCCESS;
- HANDLE Handle = INVALID_HANDLE_VALUE;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- - PVOID Buffer = LowIoContext->ParamsFor.IoCtl.pInputBuffer, EaBuffer;
- + const PVOID Buffer = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + PVOID EaBuffer;
- ULONG BufferLen = LowIoContext->ParamsFor.IoCtl.InputBufferLength, EaLength;
- UNICODE_STRING FileName;
- BOOLEAN Wait = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT);
- @@ -1693,7 +1694,7 @@ NTSTATUS nfs41_DeleteConnection(
- {
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- - PWCHAR ConnectName = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const PWCHAR ConnectName = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- ULONG ConnectNameLen = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- HANDLE Handle;
- UNICODE_STRING FileName;
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index ca3b76f..e9d28f7 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -240,7 +240,7 @@ out:
- NTSTATUS unmarshal_nfs41_open(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
- index 9662e8c..63ed061 100644
- --- a/sys/nfs41sys_readwrite.c
- +++ b/sys/nfs41sys_readwrite.c
- @@ -161,7 +161,7 @@ out:
- NTSTATUS unmarshal_nfs41_rw(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- NTSTATUS status = STATUS_SUCCESS;
- diff --git a/sys/nfs41sys_reparse.c b/sys/nfs41sys_reparse.c
- index 5d850b3..d774fd0 100644
- --- a/sys/nfs41sys_reparse.c
- +++ b/sys/nfs41sys_reparse.c
- @@ -76,8 +76,10 @@ NTSTATUS nfs41_SetReparsePoint(
- IN OUT PRX_CONTEXT RxContext)
- {
- NTSTATUS status;
- - __notnull XXCTL_LOWIO_COMPONENT *FsCtl = &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PREPARSE_DATA_BUFFER Reparse = (PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- + __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- + &RxContext->LowIoContext.ParamsFor.FsCtl;
- + __notnull const PREPARSE_DATA_BUFFER Reparse =
- + (const PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- DbgEn();
- FsRtlEnterFileSystem();
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index 77fe26e..9ee03f2 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -121,7 +121,7 @@ out:
- void unmarshal_nfs41_symlink(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- if (cur->opcode == NFS41_SYSOP_SYMLINK_SET)
- return;
- @@ -172,7 +172,8 @@ NTSTATUS check_nfs41_setsymlinkreparse_args(
- {
- NTSTATUS status = STATUS_SUCCESS;
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl = &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PREPARSE_DATA_BUFFER Reparse = (PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- + __notnull const PREPARSE_DATA_BUFFER Reparse =
- + (const PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- @@ -241,7 +242,8 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- NTSTATUS status;
- UNICODE_STRING TargetName;
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl = &RxContext->LowIoContext.ParamsFor.FsCtl;
- - __notnull PREPARSE_DATA_BUFFER Reparse = (PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- + __notnull const PREPARSE_DATA_BUFFER Reparse =
- + (const PREPARSE_DATA_BUFFER)FsCtl->pInputBuffer;
- __notnull PNFS41_FOBX Fobx = NFS41GetFobxExtension(RxContext->pFobx);
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index 7afc19f..fef489d 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -142,7 +142,7 @@ void nfs41_downcall_free_updowncall_entry(nfs41_updowncall_entry *entry)
- static void unmarshal_nfs41_header(
- nfs41_updowncall_entry *tmp,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- RtlCopyMemory(&tmp->xid, *buf, sizeof(tmp->xid));
- *buf += sizeof(tmp->xid);
- @@ -164,7 +164,7 @@ void unmarshal_nfs41_attrget(
- nfs41_updowncall_entry *cur,
- PVOID attr_value,
- ULONG *attr_len,
- - unsigned char **buf,
- + const unsigned char *restrict *restrict buf,
- BOOL copy_partial)
- {
- ULONG buf_len;
- @@ -612,9 +612,9 @@ NTSTATUS nfs41_downcall(
- NTSTATUS status = STATUS_SUCCESS;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- - ULONG in_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- + ULONG inbuf_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- - unsigned char *buf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const unsigned char *inbuf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- PLIST_ENTRY pEntry;
- nfs41_updowncall_entry *tmp, *cur= NULL;
- BOOLEAN found = 0;
- @@ -622,7 +622,7 @@ NTSTATUS nfs41_downcall(
- FsRtlEnterFileSystem();
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- - print_hexbuf("downcall buffer", buf, in_len);
- + print_hexbuf("downcall buffer", inbuf, inbuf_len);
- #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- #ifdef USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM
- @@ -637,7 +637,7 @@ NTSTATUS nfs41_downcall(
- }
- #endif /* USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM */
- - unmarshal_nfs41_header(tmp, &buf);
- + unmarshal_nfs41_header(tmp, &inbuf);
- ExAcquireFastMutexUnsafe(&downcalllist.lock);
- pEntry = &downcalllist.head;
- @@ -715,53 +715,53 @@ NTSTATUS nfs41_downcall(
- if (!tmp->status) {
- switch (tmp->opcode) {
- case NFS41_SYSOP_MOUNT:
- - unmarshal_nfs41_mount(cur, &buf);
- + unmarshal_nfs41_mount(cur, &inbuf);
- break;
- case NFS41_SYSOP_WRITE:
- case NFS41_SYSOP_READ:
- - status = unmarshal_nfs41_rw(cur, &buf);
- + status = unmarshal_nfs41_rw(cur, &inbuf);
- break;
- case NFS41_SYSOP_OPEN:
- - status = unmarshal_nfs41_open(cur, &buf);
- + status = unmarshal_nfs41_open(cur, &inbuf);
- break;
- case NFS41_SYSOP_DIR_QUERY:
- - status = unmarshal_nfs41_dirquery(cur, &buf);
- + status = unmarshal_nfs41_dirquery(cur, &inbuf);
- break;
- case NFS41_SYSOP_FILE_QUERY:
- case NFS41_SYSOP_FILE_QUERY_TIME_BASED_COHERENCY:
- - unmarshal_nfs41_getattr(cur, &buf);
- + unmarshal_nfs41_getattr(cur, &inbuf);
- break;
- case NFS41_SYSOP_EA_GET:
- - unmarshal_nfs41_eaget(cur, &buf);
- + unmarshal_nfs41_eaget(cur, &inbuf);
- break;
- case NFS41_SYSOP_SYMLINK_GET:
- case NFS41_SYSOP_SYMLINK_SET:
- - unmarshal_nfs41_symlink(cur, &buf);
- + unmarshal_nfs41_symlink(cur, &inbuf);
- break;
- case NFS41_SYSOP_VOLUME_QUERY:
- - unmarshal_nfs41_volume(cur, &buf);
- + unmarshal_nfs41_volume(cur, &inbuf);
- break;
- case NFS41_SYSOP_ACL_QUERY:
- - status = unmarshal_nfs41_getacl(cur, &buf);
- + status = unmarshal_nfs41_getacl(cur, &inbuf);
- break;
- case NFS41_SYSOP_FILE_SET:
- - unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &buf);
- + unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &inbuf);
- break;
- case NFS41_SYSOP_EA_SET:
- - unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &buf);
- + unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &inbuf);
- break;
- case NFS41_SYSOP_ACL_SET:
- - unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &buf);
- + unmarshal_nfs41_setattr(cur, &cur->ChangeTime, &inbuf);
- break;
- case NFS41_SYSOP_FSCTL_QUERYALLOCATEDRANGES:
- - unmarshal_nfs41_queryallocatedranges(cur, &buf);
- + unmarshal_nfs41_queryallocatedranges(cur, &inbuf);
- break;
- case NFS41_SYSOP_FSCTL_SET_ZERO_DATA:
- - unmarshal_nfs41_setzerodata(cur, &buf);
- + unmarshal_nfs41_setzerodata(cur, &inbuf);
- break;
- case NFS41_SYSOP_FSCTL_DUPLICATE_DATA:
- case NFS41_SYSOP_FSCTL_OFFLOAD_DATACOPY:
- - unmarshal_nfs41_duplicatedata(cur, &buf);
- + unmarshal_nfs41_duplicatedata(cur, &inbuf);
- break;
- }
- }
- @@ -813,9 +813,9 @@ NTSTATUS nfs41_delayxid(
- NTSTATUS status = STATUS_SUCCESS;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- - ULONG in_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- + ULONG inbuf_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- - unsigned char *buf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const unsigned char *inbuf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- PLIST_ENTRY pEntry;
- nfs41_updowncall_entry *cur = NULL;
- BOOLEAN found = FALSE;
- @@ -823,17 +823,17 @@ NTSTATUS nfs41_delayxid(
- FsRtlEnterFileSystem();
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- - print_hexbuf("delayxid buffer", buf, in_len);
- + print_hexbuf("delayxid buffer", inbuf, inbuf_len);
- #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- LONGLONG delayxid;
- LONGLONG moredelay;
- /* Unmarshal XID+delay value */
- - RtlCopyMemory(&delayxid, buf, sizeof(delayxid));
- - buf += sizeof(delayxid);
- - RtlCopyMemory(&moredelay, buf, sizeof(moredelay));
- - /* buf += sizeof(delay); */
- + RtlCopyMemory(&delayxid, inbuf, sizeof(delayxid));
- + inbuf += sizeof(delayxid);
- + RtlCopyMemory(&moredelay, inbuf, sizeof(moredelay));
- + /* inbuf += sizeof(delay); */
- ExAcquireFastMutexUnsafe(&downcalllist.lock);
- pEntry = &downcalllist.head;
- diff --git a/sys/nfs41sys_volinfo.c b/sys/nfs41sys_volinfo.c
- index 0363c2e..2caad54 100644
- --- a/sys/nfs41sys_volinfo.c
- +++ b/sys/nfs41sys_volinfo.c
- @@ -101,7 +101,7 @@ out:
- void unmarshal_nfs41_volume(
- nfs41_updowncall_entry *cur,
- - unsigned char **buf)
- + const unsigned char *restrict *restrict buf)
- {
- unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf, TRUE);
- }
- --
- 2.51.0
- From 70d5455fe1153045e2cd9012d484e54384061fc4 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 14:32:56 +0200
- Subject: [PATCH 2/6] sys: Kernel module should verify that it consumes all
- |IOCTL_NFS41_WRITE| downcall bytes+fix issues
- Kernel module should verify that it consumes all |IOCTL_NFS41_WRITE|
- downcall bytes, plus fix existing issues.
- |IOCTL_NFS41_WRITE| will now return |STATUS_BUFFER_OVERFLOW| if not
- all downcall bytes were processed.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_acl.c | 1 +
- sys/nfs41sys_fileinfo.c | 6 +++--
- sys/nfs41sys_fsctl.c | 4 ++-
- sys/nfs41sys_mount.c | 1 +
- sys/nfs41sys_openclose.c | 1 +
- sys/nfs41sys_readwrite.c | 3 ++-
- sys/nfs41sys_symlink.c | 1 +
- sys/nfs41sys_updowncall.c | 55 ++++++++++++++++++++++++++++++++-------
- 8 files changed, 59 insertions(+), 13 deletions(-)
- diff --git a/sys/nfs41sys_acl.c b/sys/nfs41sys_acl.c
- index d2c0a6e..e077b26 100644
- --- a/sys/nfs41sys_acl.c
- +++ b/sys/nfs41sys_acl.c
- @@ -151,6 +151,7 @@ NTSTATUS unmarshal_nfs41_getacl(
- goto out;
- }
- RtlCopyMemory(cur->buf, *buf, buf_len);
- + *buf += buf_len;
- if (buf_len > cur->buf_len)
- cur->status = STATUS_BUFFER_TOO_SMALL;
- cur->buf_len = buf_len;
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index bc84e30..a2cc9c1 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -143,7 +143,8 @@ void unmarshal_nfs41_setattr(
- PULONGLONG dest_buf,
- const unsigned char *restrict *restrict buf)
- {
- - RtlCopyMemory(dest_buf, *buf, sizeof(ULONGLONG));
- + RtlCopyMemory(dest_buf, *buf, sizeof(*dest_buf));
- + *buf += sizeof(*dest_buf);
- #ifdef DEBUG_MARSHAL_DETAIL
- DbgP("unmarshal_nfs41_setattr: returned ChangeTime %llu\n", *dest_buf);
- #endif
- @@ -154,7 +155,8 @@ void unmarshal_nfs41_getattr(
- const unsigned char *restrict *restrict buf)
- {
- unmarshal_nfs41_attrget(cur, cur->buf, &cur->buf_len, buf, FALSE);
- - RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- + RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(cur->ChangeTime));
- + *buf += sizeof(cur->ChangeTime);
- #ifdef DEBUG_MARSHAL_DETAIL
- if (cur->u.QueryFile.InfoClass == FileBasicInformation)
- DbgP("[unmarshal_nfs41_getattr] ChangeTime %llu\n", cur->ChangeTime);
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 4a5d3f6..0e1ba89 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -571,7 +571,8 @@ NTSTATUS unmarshal_nfs41_setzerodata(
- {
- NTSTATUS status = STATUS_SUCCESS;
- - RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- + RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(cur->ChangeTime));
- + *buf += sizeof(cur->ChangeTime);
- DbgP("unmarshal_nfs41_setzerodata: returned ChangeTime %llu\n",
- cur->ChangeTime);
- @@ -889,6 +890,7 @@ NTSTATUS unmarshal_nfs41_duplicatedata(
- NTSTATUS status = STATUS_SUCCESS;
- RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- + *buf += sizeof(cur->ChangeTime);
- DbgP("unmarshal_nfs41_duplicatedata: returned ChangeTime %llu\n",
- cur->ChangeTime);
- diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
- index c480c22..7133e72 100644
- --- a/sys/nfs41sys_mount.c
- +++ b/sys/nfs41sys_mount.c
- @@ -186,6 +186,7 @@ void unmarshal_nfs41_mount(
- *buf += sizeof(DWORD);
- RtlCopyMemory(cur->u.Mount.FsAttrs, *buf,
- sizeof(NFS41_FILE_FS_ATTRIBUTE_INFORMATION));
- + *buf += sizeof(NFS41_FILE_FS_ATTRIBUTE_INFORMATION);
- #ifdef DEBUG_MARSHAL_DETAIL
- DbgP("unmarshal_nfs41_mount: session=0x%p version=%d lease_time "
- "%d\n",
- diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
- index e9d28f7..8c6e287 100644
- --- a/sys/nfs41sys_openclose.c
- +++ b/sys/nfs41sys_openclose.c
- @@ -301,6 +301,7 @@ NTSTATUS unmarshal_nfs41_open(
- }
- RtlCopyMemory(cur->u.Open.symlink.Buffer, *buf,
- cur->u.Open.symlink.Length);
- + *buf += cur->u.Open.symlink.Length;
- cur->u.Open.symlink.Buffer[cur->u.Open.symlink.Length/sizeof(wchar_t)] =
- L'\0';
- #ifdef DEBUG_MARSHAL_DETAIL
- diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
- index 63ed061..f1eface 100644
- --- a/sys/nfs41sys_readwrite.c
- +++ b/sys/nfs41sys_readwrite.c
- @@ -167,7 +167,8 @@ NTSTATUS unmarshal_nfs41_rw(
- RtlCopyMemory(&cur->buf_len, *buf, sizeof(cur->buf_len));
- *buf += sizeof(cur->buf_len);
- - RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
- + RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(cur->ChangeTime));
- + *buf += sizeof(cur->ChangeTime);
- #ifdef DEBUG_MARSHAL_DETAIL_RW
- DbgP("unmarshal_nfs41_rw: returned len %lu ChangeTime %llu\n",
- cur->buf_len, cur->ChangeTime);
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index 9ee03f2..c669565 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -135,6 +135,7 @@ void unmarshal_nfs41_symlink(
- }
- RtlCopyMemory(cur->u.Symlink.target->Buffer, *buf,
- cur->u.Symlink.target->Length);
- + *buf += cur->u.Symlink.target->Length;
- }
- NTSTATUS map_symlink_errors(
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index fef489d..78ec5a2 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -168,7 +168,10 @@ void unmarshal_nfs41_attrget(
- BOOL copy_partial)
- {
- ULONG buf_len;
- - RtlCopyMemory(&buf_len, *buf, sizeof(ULONG));
- +
- + RtlCopyMemory(&buf_len, *buf, sizeof(buf_len));
- + *buf += sizeof(ULONG);
- +
- if (copy_partial) {
- if (buf_len > *attr_len) {
- cur->status = STATUS_BUFFER_OVERFLOW;
- @@ -182,7 +185,6 @@ void unmarshal_nfs41_attrget(
- }
- }
- - *buf += sizeof(ULONG);
- *attr_len = buf_len;
- RtlCopyMemory(attr_value, *buf, buf_len);
- *buf += buf_len;
- @@ -611,14 +613,15 @@ NTSTATUS nfs41_downcall(
- {
- NTSTATUS status = STATUS_SUCCESS;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- -#ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- ULONG inbuf_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- -#endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- - const unsigned char *inbuf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const unsigned char *inbuf;
- + const unsigned char *inbuf_orig;
- PLIST_ENTRY pEntry;
- nfs41_updowncall_entry *tmp, *cur= NULL;
- BOOLEAN found = 0;
- + inbuf = inbuf_orig = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- +
- FsRtlEnterFileSystem();
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- @@ -764,6 +767,25 @@ NTSTATUS nfs41_downcall(
- unmarshal_nfs41_duplicatedata(cur, &inbuf);
- break;
- }
- +
- + /*
- + * Verify that we really read all bytes send by the userland daemon!
- + * (|NFS41_SYSOP_VOLUME_QUERY| is exempt from this test, because most
- + * volume queries allows partial reads from |inbuf| if the caller
- + * passes a buffer which is too small)
- + */
- + ULONG bytesread_from_inbuf = (ULONG)(inbuf - inbuf_orig);
- + if ((tmp->opcode != NFS41_SYSOP_VOLUME_QUERY) &&
- + (bytesread_from_inbuf != inbuf_len)) {
- + print_error("nfs41_downcall: ASSERT: '%s': "
- + "(inbuf(=0x%p)-inbuf_orig(=0x%p))(=%ld) != inbuf_len(=%ld)\n",
- + opcode2string(tmp->opcode),
- + inbuf,
- + inbuf_orig,
- + (long)bytesread_from_inbuf,
- + (long)inbuf_len);
- + status = STATUS_BUFFER_OVERFLOW;
- + }
- }
- ExReleaseFastMutexUnsafe(&cur->lock);
- if (cur->async_op) {
- @@ -812,16 +834,17 @@ NTSTATUS nfs41_delayxid(
- {
- NTSTATUS status = STATUS_SUCCESS;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- -#ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- ULONG inbuf_len = LowIoContext->ParamsFor.IoCtl.InputBufferLength;
- -#endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- - const unsigned char *inbuf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- + const unsigned char *inbuf;
- + const unsigned char *inbuf_orig;
- PLIST_ENTRY pEntry;
- nfs41_updowncall_entry *cur = NULL;
- BOOLEAN found = FALSE;
- FsRtlEnterFileSystem();
- + inbuf = inbuf_orig = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
- +
- #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
- print_hexbuf("delayxid buffer", inbuf, inbuf_len);
- #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
- @@ -833,7 +856,21 @@ NTSTATUS nfs41_delayxid(
- RtlCopyMemory(&delayxid, inbuf, sizeof(delayxid));
- inbuf += sizeof(delayxid);
- RtlCopyMemory(&moredelay, inbuf, sizeof(moredelay));
- - /* inbuf += sizeof(delay); */
- + inbuf += sizeof(moredelay);
- +
- + /*
- + * Verify that we really read all bytes send by the userland daemon!
- + */
- + ULONG bytesread_from_inbuf = (ULONG)(inbuf - inbuf_orig);
- + if (bytesread_from_inbuf != inbuf_len) {
- + print_error("nfs41_delayxid: ASSERT: "
- + "(inbuf(=0x%p)-inbuf_orig(=0x%p))(=%ld) != inbuf_len(=%ld)\n",
- + inbuf,
- + inbuf_orig,
- + (long)bytesread_from_inbuf,
- + (long)inbuf_len);
- + status = STATUS_BUFFER_OVERFLOW;
- + }
- ExAcquireFastMutexUnsafe(&downcalllist.lock);
- pEntry = &downcalllist.head;
- --
- 2.51.0
- From 56076d38c86c5f8801bf7b1bf26002c544c10ba3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 17:13:43 +0200
- Subject: [PATCH 3/6] daemon: updowncall utility functions should use
- |const|+|restrict|
- updowncall utility functions should use |const|+|restrict|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.c | 67 +++++++++++++++++++++++++++------------------------
- daemon/util.h | 17 +++++++------
- 2 files changed, 45 insertions(+), 39 deletions(-)
- diff --git a/daemon/util.c b/daemon/util.c
- index a9c96a3..1c284d9 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -41,7 +41,8 @@ char *stpcpy(char *restrict s1, const char *restrict s2)
- return ((char *)memcpy(s1, s2, (l+1)*sizeof(char))) + l*sizeof(char);
- }
- -int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len)
- +int safe_read(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, void *dest, uint32_t dest_len)
- {
- if (*remaining < dest_len)
- return ERROR_BUFFER_OVERFLOW;
- @@ -57,7 +58,8 @@ int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t des
- * have enough buffer space left, and in that case return current buffer
- * position in |destbuffer|
- */
- -int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t src_len, void **destbuffer)
- +int get_safe_read_bufferpos(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, uint32_t src_len, const void **destbuffer)
- {
- if (*remaining < src_len)
- return ERROR_BUFFER_OVERFLOW;
- @@ -68,8 +70,36 @@ int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t s
- return ERROR_SUCCESS;
- }
- +int get_name(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, const char *restrict *restrict out_name)
- +{
- + int status;
- + USHORT len;
- + const char *name;
- +
- + status = safe_read(pos, remaining, &len, sizeof(USHORT));
- + if (status) goto out;
- + if (*remaining < len) {
- + status = ERROR_BUFFER_OVERFLOW;
- + goto out;
- + }
- +
- + name = (const char *)*pos;
- +
- + EASSERT_MSG((name[len-1] == '\0'),
- + ("name='%s', (len-1)=%d, expected 0x00, got 0x%x\n",
- + name, (int)(len-1), (int)name[len-1]));
- +
- + *out_name = name;
- + *pos += len;
- + *remaining -= len;
- +
- +out:
- + return status;
- +}
- -int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src_len)
- +int safe_write(unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, const void *src, uint32_t src_len)
- {
- if (*remaining < src_len)
- return ERROR_BUFFER_OVERFLOW;
- @@ -85,7 +115,8 @@ int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src
- * have enough buffer space left, and in that case return current buffer
- * position in |destbuffer|
- */
- -int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t src_len, void **destbuffer)
- +int get_safe_write_bufferpos(unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, uint32_t src_len, void **destbuffer)
- {
- if (*remaining < src_len)
- return ERROR_BUFFER_OVERFLOW;
- @@ -96,34 +127,6 @@ int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t
- return ERROR_SUCCESS;
- }
- -
- -int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
- -{
- - int status;
- - USHORT len;
- - const char *name;
- -
- - status = safe_read(pos, remaining, &len, sizeof(USHORT));
- - if (status) goto out;
- - if (*remaining < len) {
- - status = ERROR_BUFFER_OVERFLOW;
- - goto out;
- - }
- -
- - name = (const char *)*pos;
- -
- - EASSERT_MSG((name[len-1] == '\0'),
- - ("name='%s', (len-1)=%d, expected 0x00, got 0x%x\n",
- - name, (int)(len-1), (int)name[len-1]));
- -
- - *out_name = name;
- - *pos += len;
- - *remaining -= len;
- -
- -out:
- - return status;
- -}
- -
- const char* strip_path(
- IN const char *path,
- OUT uint32_t *len_out)
- diff --git a/daemon/util.h b/daemon/util.h
- index a424442..bb3fbaa 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -93,13 +93,16 @@ void *memrchr(const void * restrict s, int c, size_t n)
- return NULL;
- }
- -int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- -int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining,
- - uint32_t src_len, void **destbuffer);
- -int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- -int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining,
- - uint32_t src_len, void **destbuffer);
- -int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name);
- +int safe_read(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, void *dest, uint32_t dest_len);
- +int get_safe_read_bufferpos(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, uint32_t src_len, const void **destbuffer);
- +int get_name(const unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, const char *restrict *restrict out_name);
- +int safe_write(unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, const void *src, uint32_t src_len);
- +int get_safe_write_bufferpos(unsigned char *restrict *restrict pos,
- + uint32_t *restrict remaining, uint32_t src_len, void **destbuffer);
- const char* strip_path(
- IN const char *path,
- --
- 2.51.0
- From c0239b45aeef3e7817ba9060d4a5e70f17a07d13 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 18:35:52 +0200
- Subject: [PATCH 4/6] build.vc19: Do not use the (debug) |memcpy_inline()|
- function
- Do not use the (debug) |memcpy_inline()| function. It causes
- inteference with debuggers and DrMemory, and DrMemory does
- the job better anyway.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- build.vc19/libtirpc/libtirpc.vcxproj | 12 ++++++------
- build.vc19/nfs41_np/nfs41_np.vcxproj | 12 ++++++------
- build.vc19/nfs_install/nfs_install.vcxproj | 12 ++++++------
- build.vc19/nfs_mount/nfs_mount.vcxproj | 12 ++++++------
- build.vc19/nfsd/nfsd.vcxproj | 12 ++++++------
- 5 files changed, 30 insertions(+), 30 deletions(-)
- diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
- index 815629f..4034b0b 100644
- --- a/build.vc19/libtirpc/libtirpc.vcxproj
- +++ b/build.vc19/libtirpc/libtirpc.vcxproj
- @@ -126,7 +126,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- @@ -152,7 +152,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- @@ -178,7 +178,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- @@ -204,7 +204,7 @@
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- @@ -234,7 +234,7 @@
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- @@ -264,7 +264,7 @@
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- diff --git a/build.vc19/nfs41_np/nfs41_np.vcxproj b/build.vc19/nfs41_np/nfs41_np.vcxproj
- index e922c2e..5806707 100644
- --- a/build.vc19/nfs41_np/nfs41_np.vcxproj
- +++ b/build.vc19/nfs41_np/nfs41_np.vcxproj
- @@ -129,7 +129,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -150,7 +150,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -171,7 +171,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -193,7 +193,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -217,7 +217,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -241,7 +241,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- diff --git a/build.vc19/nfs_install/nfs_install.vcxproj b/build.vc19/nfs_install/nfs_install.vcxproj
- index 19b133e..192bdaf 100644
- --- a/build.vc19/nfs_install/nfs_install.vcxproj
- +++ b/build.vc19/nfs_install/nfs_install.vcxproj
- @@ -126,7 +126,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -144,7 +144,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -162,7 +162,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -182,7 +182,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -203,7 +203,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -224,7 +224,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- diff --git a/build.vc19/nfs_mount/nfs_mount.vcxproj b/build.vc19/nfs_mount/nfs_mount.vcxproj
- index 6d590d1..ac139f7 100644
- --- a/build.vc19/nfs_mount/nfs_mount.vcxproj
- +++ b/build.vc19/nfs_mount/nfs_mount.vcxproj
- @@ -132,7 +132,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -151,7 +151,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -170,7 +170,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- @@ -191,7 +191,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -213,7 +213,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- @@ -235,7 +235,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
- index 7cfa57a..e38f629 100644
- --- a/build.vc19/nfsd/nfsd.vcxproj
- +++ b/build.vc19/nfsd/nfsd.vcxproj
- @@ -132,7 +132,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
- @@ -157,7 +157,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
- @@ -183,7 +183,7 @@
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
- @@ -210,7 +210,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BufferSecurityCheck>false</BufferSecurityCheck>
- @@ -238,7 +238,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BufferSecurityCheck>false</BufferSecurityCheck>
- @@ -267,7 +267,7 @@
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_WINTIRPC;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;_MEMCPY_INLINE_=1;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <BufferSecurityCheck>false</BufferSecurityCheck>
- --
- 2.51.0
- From 055b2219765ba62fbb7a93f6a35d26323732e37c Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 19:59:20 +0200
- Subject: [PATCH 5/6] daemon: Use |restrict|+|const| for |parse_*()| upcall
- functions
- Use |restrict|+|const| for |parse_*()| upcall functions.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 12 ++++++++----
- daemon/ea.c | 10 ++++++++--
- daemon/fsctl.c | 18 ++++++++++++------
- daemon/getattr.c | 5 ++++-
- daemon/lock.c | 10 ++++++++--
- daemon/mount.c | 9 +++++++--
- daemon/open.c | 15 ++++++++++++---
- daemon/readdir.c | 5 ++++-
- daemon/readwrite.c | 5 ++++-
- daemon/setattr.c | 5 ++++-
- daemon/symlink.c | 8 ++++++--
- daemon/upcall.c | 2 +-
- daemon/upcall.h | 7 +++++--
- daemon/volume.c | 5 ++++-
- 14 files changed, 87 insertions(+), 29 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index c37a7c8..a2f2749 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -55,8 +55,10 @@ static void map_winaccessmask2nfs4acemask(ACCESS_MASK win_mask,
- static void map_nfs4acemask2winaccessmask(uint32_t nfs4_mask,
- int file_type, bool named_attr_support, ACCESS_MASK *win_mask);
- -static int parse_getacl(unsigned char *buffer, uint32_t length,
- - nfs41_upcall *upcall)
- +static int parse_getacl(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- getacl_upcall_args *args = &upcall->args.getacl;
- @@ -518,8 +520,10 @@ const nfs41_upcall_op nfs41_op_getacl = {
- .arg_size = sizeof(getacl_upcall_args)
- };
- -static int parse_setacl(unsigned char *buffer, uint32_t length,
- - nfs41_upcall *upcall)
- +static int parse_setacl(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- setacl_upcall_args *args = &upcall->args.setacl;
- diff --git a/daemon/ea.c b/daemon/ea.c
- index b6f1613..f33c757 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -187,7 +187,10 @@ out:
- /* NFS41_SYSOP_EA_SET */
- -static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_setexattr(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- setexattr_upcall_args *args = &upcall->args.setexattr;
- @@ -264,7 +267,10 @@ static int marshall_setexattr(unsigned char *buffer, uint32_t *length, nfs41_upc
- /* NFS41_SYSOP_EA_GET */
- -static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_getexattr(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- getexattr_upcall_args *args = &upcall->args.getexattr;
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index dbc76f6..096d207 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -31,8 +31,10 @@
- #define SZDLVL 2 /* dprintf level for "set zero data" logging */
- #define DDLVL 2 /* dprintf level for "duplicate data" logging */
- -static int parse_queryallocatedranges(unsigned char *buffer,
- - uint32_t length, nfs41_upcall *upcall)
- +static int parse_queryallocatedranges(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- queryallocatedranges_upcall_args *args = &upcall->args.queryallocatedranges;
- @@ -319,8 +321,10 @@ const nfs41_upcall_op nfs41_op_queryallocatedranges = {
- .arg_size = sizeof(queryallocatedranges_upcall_args)
- };
- -static int parse_setzerodata(unsigned char *buffer,
- - uint32_t length, nfs41_upcall *upcall)
- +static int parse_setzerodata(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- setzerodata_upcall_args *args = &upcall->args.setzerodata;
- @@ -438,8 +442,10 @@ const nfs41_upcall_op nfs41_op_setzerodata = {
- .arg_size = sizeof(setzerodata_upcall_args)
- };
- -static int parse_duplicatedata(unsigned char *buffer,
- - uint32_t length, nfs41_upcall *upcall)
- +static int parse_duplicatedata(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- duplicatedata_upcall_args *args = &upcall->args.duplicatedata;
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index f5622d2..bc6709f 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -83,7 +83,10 @@ int nfs41_cached_getattr(
- }
- /* NFS41_SYSOP_FILE_QUERY, NFS41_SYSOP_FILE_QUERY_TIME_BASED_COHERENCY */
- -static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_getattr(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- diff --git a/daemon/lock.c b/daemon/lock.c
- index 7588a3c..03958b5 100644
- --- a/daemon/lock.c
- +++ b/daemon/lock.c
- @@ -168,7 +168,10 @@ static void open_unlock_remove(
- /* NFS41_SYSOP_LOCK */
- -static int parse_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_lock(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- lock_upcall_args *args = &upcall->args.lock;
- @@ -351,7 +354,10 @@ out:
- /* NFS41_SYSOP_UNLOCK */
- -static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_unlock(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- unlock_upcall_args *args = &upcall->args.unlock;
- diff --git a/daemon/mount.c b/daemon/mount.c
- index 2105375..88c3067 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -36,7 +36,10 @@
- /* NFS41_SYSOP_MOUNT */
- -static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_mount(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- mount_upcall_args *args = &upcall->args.mount;
- @@ -346,7 +349,9 @@ const nfs41_upcall_op nfs41_op_mount = {
- /* NFS41_SYSOP_UNMOUNT */
- -static int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_unmount(const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- DPRINTF(1, ("parsing NFS41_SYSOP_UNMOUNT: root=0x%p\n", upcall->root_ref));
- diff --git a/daemon/open.c b/daemon/open.c
- index d93ec60..bad410b 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -299,7 +299,10 @@ static int open_or_delegate(
- }
- -static int parse_abs_path(unsigned char **buffer, uint32_t *length, nfs41_abs_path *path)
- +static int parse_abs_path(
- + const unsigned char **restrict buffer,
- + uint32_t *restrict length,
- + nfs41_abs_path *restrict path)
- {
- int status = safe_read(buffer, length, &path->len, sizeof(USHORT));
- if (status) goto out;
- @@ -317,7 +320,10 @@ out:
- }
- /* NFS41_SYSOP_OPEN */
- -static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_open(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- open_upcall_args *args = &upcall->args.open;
- @@ -1347,7 +1353,10 @@ out:
- /* NFS41_SYSOP_CLOSE */
- -static int parse_close(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_close(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- close_upcall_args *args = &upcall->args.close;
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index 407bcfb..c7f0d18 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -263,7 +263,10 @@ typedef union _FILE_DIR_INFO_UNION {
- /* NFS41_SYSOP_DIR_QUERY */
- -static int parse_readdir(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_readdir(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- readdir_upcall_args *args = &upcall->args.readdir;
- diff --git a/daemon/readwrite.c b/daemon/readwrite.c
- index 2be92b6..4dd610f 100644
- --- a/daemon/readwrite.c
- +++ b/daemon/readwrite.c
- @@ -38,7 +38,10 @@
- const stateid4 special_read_stateid = {0xffffffff,
- {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
- -static int parse_rw(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_rw(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- readwrite_upcall_args *args = &upcall->args.rw;
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index fe920a2..aba6aee 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -42,7 +42,10 @@
- #endif
- /* NFS41_SYSOP_FILE_SET */
- -static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_setattr(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- setattr_upcall_args *args = &upcall->args.setattr;
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index 2eb947b..49c3271 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -236,7 +236,9 @@ out:
- /* NFS41_SYSOP_SYMLINK_GET */
- -static int parse_symlink_get(unsigned char *buffer, uint32_t length,
- +static int parse_symlink_get(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- nfs41_upcall *upcall)
- {
- symlink_upcall_args *args = &upcall->args.symlink;
- @@ -332,7 +334,9 @@ const nfs41_upcall_op nfs41_op_symlink_get = {
- };
- /* NFS41_SYSOP_SYMLINK_SET */
- -static int parse_symlink_set(unsigned char *buffer, uint32_t length,
- +static int parse_symlink_set(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- nfs41_upcall *upcall)
- {
- symlink_upcall_args *args = &upcall->args.symlink;
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index 53433c4..afd7130 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -87,7 +87,7 @@ static const uint32_t g_upcall_op_table_size = ARRAYSIZE(g_upcall_op_table);
- int upcall_parse(
- - IN unsigned char *buffer,
- + IN const unsigned char *restrict buffer,
- IN uint32_t length,
- OUT nfs41_upcall *upcall)
- {
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index b16719b..43016e5 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.h
- @@ -282,7 +282,10 @@ typedef struct __nfs41_upcall {
- /* upcall operation interface */
- -typedef int (*upcall_parse_proc)(unsigned char*, uint32_t, nfs41_upcall*);
- +typedef int (*upcall_parse_proc)(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall);
- typedef int (*upcall_handle_proc)(void*, nfs41_upcall*);
- typedef int (*upcall_marshall_proc)(unsigned char*, uint32_t*, nfs41_upcall*);
- typedef void (*upcall_cancel_proc)(nfs41_upcall*);
- @@ -300,7 +303,7 @@ typedef struct __nfs41_upcall_op {
- /* upcall.c */
- int upcall_parse(
- - IN unsigned char *buffer,
- + IN const unsigned char *restrict buffer,
- IN uint32_t length,
- OUT nfs41_upcall *upcall);
- diff --git a/daemon/volume.c b/daemon/volume.c
- index 2eb29bc..8a6ef44 100644
- --- a/daemon/volume.c
- +++ b/daemon/volume.c
- @@ -45,7 +45,10 @@
- /* NFS41_SYSOP_VOLUME_QUERY */
- -static int parse_volume(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- +static int parse_volume(
- + const unsigned char *restrict buffer,
- + uint32_t length,
- + nfs41_upcall *upcall)
- {
- int status;
- volume_upcall_args *args = &upcall->args.volume;
- --
- 2.51.0
- From 281309b5bc9aab734ad42396ab8f4284f3c4a754 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 6 Oct 2025 21:09:28 +0200
- Subject: [PATCH 6/6] daemon: Fix clang |const| warnings
- Fix clang |const| warnings.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 2 +-
- daemon/ea.c | 4 ++--
- daemon/lock.c | 4 ++--
- daemon/open.c | 2 +-
- daemon/setattr.c | 2 +-
- 5 files changed, 7 insertions(+), 7 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index a2f2749..d2baf96 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -527,7 +527,7 @@ static int parse_setacl(
- {
- int status;
- setacl_upcall_args *args = &upcall->args.setacl;
- - void *sec_desc_ptr;
- + const void *sec_desc_ptr;
- ULONG sec_desc_len;
- status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
- diff --git a/daemon/ea.c b/daemon/ea.c
- index f33c757..5acf81b 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -202,7 +202,7 @@ static int parse_setexattr(
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- status = get_safe_read_bufferpos(&buffer, &length,
- - args->buf_len, (void **)&args->buf);
- + args->buf_len, (const void **)&args->buf);
- if (status) goto out;
- EASSERT(length == 0);
- @@ -288,7 +288,7 @@ static int parse_getexattr(
- status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
- if (status) goto out;
- status = get_safe_read_bufferpos(&buffer, &length,
- - args->ealist_len, (void **)&args->ealist);
- + args->ealist_len, (const void **)&args->ealist);
- if (status) goto out;
- EASSERT(length == 0);
- diff --git a/daemon/lock.c b/daemon/lock.c
- index 03958b5..54e05b4 100644
- --- a/daemon/lock.c
- +++ b/daemon/lock.c
- @@ -366,7 +366,7 @@ static int parse_unlock(
- if (status) goto out;
- args->buf_len = args->count*2L*sizeof(LONGLONG);
- status = get_safe_read_bufferpos(&buffer, &length,
- - args->buf_len, (void **)&args->buf);
- + args->buf_len, (const void **)&args->buf);
- if (status) goto out;
- EASSERT(length == 0);
- @@ -382,7 +382,7 @@ static int handle_unlock(void *daemon_context, nfs41_upcall *upcall)
- stateid_arg stateid;
- unlock_upcall_args *args = &upcall->args.unlock;
- nfs41_open_state *state = upcall->state_ref;
- - unsigned char *buf = args->buf;
- + const unsigned char *buf = args->buf;
- uint32_t buf_len = args->buf_len;
- uint32_t i;
- int status = NO_ERROR;
- diff --git a/daemon/open.c b/daemon/open.c
- index bad410b..1d5f30d 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -300,7 +300,7 @@ static int open_or_delegate(
- static int parse_abs_path(
- - const unsigned char **restrict buffer,
- + const unsigned char *restrict *restrict buffer,
- uint32_t *restrict length,
- nfs41_abs_path *restrict path)
- {
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index aba6aee..8705161 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -57,7 +57,7 @@ static int parse_setattr(
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- status = get_safe_read_bufferpos(&buffer, &length,
- - args->buf_len, (void **)&args->buf);
- + args->buf_len, (const void **)&args->buf);
- if (status) goto out;
- args->root = upcall->root_ref;
- --
- 2.51.0
msnfs41client: Patches for kernel downcall buffer checks, |const|+|restrict|+cleanup+misc, 2025-10-06
Posted by Anonymous on Mon 6th Oct 2025 20:21
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.