- From 321ad53e3fd42ff6f932ec6ff7fe318ffc2aaaee Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Jun 2025 12:01:56 +0200
- Subject: [PATCH 1/4] sys: |FSCTL_DUPLICATE_EXTENTS_TO_FILE| upcall timeout
- calculation should depend on byte count
- |FSCTL_DUPLICATE_EXTENTS_TO_FILE| upcall timeout calculation should
- depend the number of bytes being cloned.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_fsctl.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index d90eb6d..6845b89 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -618,6 +618,7 @@ NTSTATUS nfs41_DuplicateData(
- (PDUPLICATE_EXTENTS_DATA)FsCtl->pInputBuffer;
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- PFILE_OBJECT srcfo = NULL;
- + DWORD io_delay;
- DbgEn();
- @@ -730,7 +731,11 @@ NTSTATUS nfs41_DuplicateData(
- entry->u.DuplicateData.bytecount =
- duplicatedatabuffer->ByteCount.QuadPart;
- - status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
- + /* Add extra timeout depending on file size */
- + io_delay = (DWORD)(pVNetRootContext->timeout +
- + EXTRA_TIMEOUT_PER_BYTE(entry->u.DuplicateData.bytecount));
- +
- + status = nfs41_UpcallWaitForReply(entry, io_delay);
- if (status) {
- /* Timeout - |nfs41_downcall()| will free |entry|+contents */
- entry = NULL;
- --
- 2.45.1
- From 63907ff8792da403b567076ebde464a8dc7e826b Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Jun 2025 12:03:58 +0200
- Subject: [PATCH 2/4] daemon,nfs41_build_features.h: Remove
- |NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS| build option
- Remove |NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS|
- build option.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 60 --------------------------------
- daemon/daemon_debug.h | 5 ---
- daemon/getattr.c | 66 -----------------------------------
- daemon/nfs41.h | 3 --
- daemon/nfs41_session.c | 5 ---
- daemon/open.c | 79 ------------------------------------------
- daemon/upcall.c | 31 -----------------
- nfs41_build_features.h | 9 -----
- 8 files changed, 258 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 674bec5..6b53e94 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -1410,66 +1410,6 @@ out:
- dprintf_out("<-- debug_list_sparsefile_datasections()\n");
- }
- -#define NUM_RECENTLY_DELETED 128
- -static struct
- -{
- - SRWLOCK lock;
- - void *deleted_ptrs[NUM_RECENTLY_DELETED];
- - size_t deleted_index;
- -} ptr_recently_deleted_data = {
- - .lock = SRWLOCK_INIT,
- -};
- -
- -bool debug_ptr_was_recently_deleted(void *in_ptr)
- -{
- - size_t i;
- - bool_t res = false;
- -
- - AcquireSRWLockShared(&ptr_recently_deleted_data.lock);
- - for (i=0 ; i < NUM_RECENTLY_DELETED ; i++) {
- - if (ptr_recently_deleted_data.deleted_ptrs[i] == in_ptr) {
- - res = true;
- - break;
- - }
- - }
- - ReleaseSRWLockShared(&ptr_recently_deleted_data.lock);
- - return res;
- -}
- -
- -void debug_ptr_add_recently_deleted(void *in_ptr)
- -{
- - size_t i;
- -
- - AcquireSRWLockExclusive(&ptr_recently_deleted_data.lock);
- - i = ptr_recently_deleted_data.deleted_index++ % NUM_RECENTLY_DELETED;
- - ptr_recently_deleted_data.deleted_ptrs[i] = in_ptr;
- - ReleaseSRWLockExclusive(&ptr_recently_deleted_data.lock);
- -}
- -
- -#define NUM_DELAY_FREE 2048
- -static struct
- -{
- - SRWLOCK lock;
- - void *free_ptrs[NUM_DELAY_FREE];
- - size_t free_ptrs_index;
- -} debug_delay_free_data = {
- - .lock = SRWLOCK_INIT,
- -};
- -
- -void debug_delayed_free(void *in_ptr)
- -{
- - size_t i;
- -
- - AcquireSRWLockExclusive(&debug_delay_free_data.lock);
- - i = debug_delay_free_data.free_ptrs_index++ % NUM_DELAY_FREE;
- -
- - if (debug_delay_free_data.free_ptrs[i])
- - free(debug_delay_free_data.free_ptrs[i]);
- -
- - debug_delay_free_data.free_ptrs[i] = in_ptr;
- - ReleaseSRWLockExclusive(&debug_delay_free_data.lock);
- -}
- -
- void debug_print_ea(PFILE_FULL_EA_INFORMATION ea)
- {
- PFILE_FULL_EA_INFORMATION print_ea = ea;
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index a4408f0..f3af022 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -173,11 +173,6 @@ const char* pnfs_iomode_string(enum pnfs_iomode iomode);
- void dprint_layout(int level, const struct __pnfs_file_layout *layout);
- void dprint_device(int level, const struct __pnfs_file_device *device);
- -bool debug_ptr_was_recently_deleted(void *in_ptr);
- -void debug_ptr_add_recently_deleted(void *in_ptr);
- -
- -void debug_delayed_free(void *in_ptr);
- -
- typedef struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
- void debug_print_ea(PFILE_FULL_EA_INFORMATION ea);
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index c0ddc2b..7c8b2d1 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -66,55 +66,6 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- {
- int status;
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - EASSERT(length > 4);
- - if (length <= 4) {
- - eprintf("parse_getattr: "
- - "upcall->opcode='%s' upcall->state_ref(=0x%p) "
- - "length(=%d) < 4\n",
- - opcode2string(upcall->opcode), upcall->state_ref,
- - (int)length);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -
- - if (debug_ptr_was_recently_deleted(upcall->state_ref)) {
- - eprintf("parse_getattr: "
- - "upcall->opcode='%s' upcall->state_ref(=0x%p) was "
- - "recently deleted\n",
- - opcode2string(upcall->opcode), upcall->state_ref);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -
- - EASSERT_IS_VALID_NON_NULL_PTR(upcall->state_ref);
- - if (!DEBUG_IS_VALID_NON_NULL_PTR(upcall->state_ref)) {
- - eprintf("parse_getattr: "
- - "upcall->opcode='%s' upcall->state_ref(=0x%p) not valid\n",
- - opcode2string(upcall->opcode), upcall->state_ref);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -
- - if (!isvalidnfs41_open_state_ptr(upcall->state_ref)) {
- - eprintf("parse_getattr: upcall->opcode='%s': Error accessing "
- - "upcall->state_ref(=0x%p)->session->client\n",
- - opcode2string(upcall->opcode),
- - upcall->state_ref);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- - EASSERT(upcall->state_ref->ref_count > 0);
- - if (upcall->state_ref->ref_count == 0) {
- - eprintf("parse_getattr: upcall->opcode='%s': "
- - "upcall->state_ref(=0x%p) ref_count==0\n",
- - opcode2string(upcall->opcode),
- - upcall->state_ref);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- getattr_upcall_args *args = &upcall->args.getattr;
- status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
- if (status) goto out;
- @@ -137,23 +88,6 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- nfs41_open_state *state = upcall->state_ref;
- nfs41_file_info info = { 0 };
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - if (!DEBUG_IS_VALID_NON_NULL_PTR(state->session)) {
- - eprintf("handle_getattr: Invalid session ptr=0x%p\n",
- - (void *)state->session);
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -
- - if (!DEBUG_IS_VALID_NON_NULL_PTR(state->file.fh.superblock)) {
- - eprintf("handle_getattr: Invalid state->file.fh.superblock ptr=0x%p\n",
- - (void *)state->file.fh.superblock);
- - /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- status = nfs41_cached_getattr(state->session, &state->file, &info);
- if (status) {
- eprintf("handle_getattr(state->path.path='%s'): "
- diff --git a/daemon/nfs41.h b/daemon/nfs41.h
- index ef23599..e3443e7 100644
- --- a/daemon/nfs41.h
- +++ b/daemon/nfs41.h
- @@ -561,9 +561,6 @@ void nfs41_open_state_ref(
- void nfs41_open_state_deref(
- IN nfs41_open_state *state);
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- -bool isvalidnfs41_open_state_ptr(nfs41_open_state *state_ref);
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- struct __stateid_arg;
- void nfs41_open_stateid_arg(
- IN nfs41_open_state *state,
- diff --git a/daemon/nfs41_session.c b/daemon/nfs41_session.c
- index b4e9b7e..57dc186 100644
- --- a/daemon/nfs41_session.c
- +++ b/daemon/nfs41_session.c
- @@ -447,10 +447,5 @@ void nfs41_session_free(
- DeleteCriticalSection(&session->table.lock);
- ReleaseSRWLockExclusive(&session->client->session_lock);
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - (void)memset(session, 0, sizeof(nfs41_session));
- - debug_delayed_free(session);
- -#else
- free(session);
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- }
- diff --git a/daemon/open.c b/daemon/open.c
- index 682d04d..d1ca062 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -101,14 +101,6 @@ static void open_state_free(
- {
- struct list_entry *entry, *tmp;
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - /*
- - * Remember the pointer here so we can reject it
- - * later in |parse_getattr()|
- - */
- - debug_ptr_add_recently_deleted(state);
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- EASSERT(waitcriticalsection(&state->ea.lock) == TRUE);
- EASSERT(waitcriticalsection(&state->locks.lock) == TRUE);
- @@ -128,77 +120,13 @@ static void open_state_free(
- EASSERT(state->ref_count == 0);
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - (void)memset(state, 0, sizeof(nfs41_open_state));
- - debug_delayed_free(state);
- -#else
- free(state);
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- }
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- -bool isvalidnfs41_open_state_ptr(nfs41_open_state *state_ref)
- -{
- - /*
- - * If |>state_ref| is garbage, then this should trigger
- - * an exception
- - */
- - volatile int mark = 0;
- - __try {
- - if (state_ref != NULL) {
- - mark++;
- - if (DEBUG_IS_VALID_NON_NULL_PTR(state_ref)) {
- - mark++;
- - if (state_ref->session != NULL) {
- - mark++;
- - if (DEBUG_IS_VALID_NON_NULL_PTR(state_ref->session)) {
- - mark++;
- - if (state_ref->session->client != NULL) {
- - mark++;
- - if (DEBUG_IS_VALID_NON_NULL_PTR(state_ref->session->client)) {
- - mark++;
- - }
- - }
- - }
- - }
- - }
- - }
- - } __except(EXCEPTION_EXECUTE_HANDLER) {
- - eprintf("isvalidnfs41_open_state_ptr: Exception accessing "
- - "state_ref(=0x%p)->session->client, mark=%d\n",
- - state_ref, mark);
- - }
- -
- - if (mark == 6) {
- - return true;
- - }
- -
- - return false;
- -}
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- /* open state reference counting */
- void nfs41_open_state_ref(
- IN nfs41_open_state *state)
- {
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - /*
- - * gisburn: fixme: sometimes this happens under high parallel
- - * usage with multiple mounts - but why ?
- - * 0:038> kp
- - * Child-SP RetAddr Call Site
- - * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
- - * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
- - * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
- - * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
- - * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
- - * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
- - */
- - EASSERT_IS_VALID_NON_NULL_PTR(state);
- - if (!DEBUG_IS_VALID_NON_NULL_PTR(state))
- - return;
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- EASSERT(state->ref_count > 0);
- const LONG count = InterlockedIncrement(&state->ref_count);
- @@ -1466,13 +1394,6 @@ out:
- static void cleanup_close(nfs41_upcall *upcall)
- {
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - EASSERT(upcall->state_ref != INVALID_HANDLE_VALUE);
- - if (upcall->state_ref == INVALID_HANDLE_VALUE) {
- - return;
- - }
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- /* release the initial reference from create_open_state() */
- nfs41_open_state_deref(upcall->state_ref);
- }
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index fe19deb..2f200a7 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -148,37 +148,6 @@ int upcall_parse(
- if (upcall->root_ref != INVALID_HANDLE_VALUE)
- nfs41_root_ref(upcall->root_ref);
- -#ifdef NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS
- - if (upcall->state_ref != INVALID_HANDLE_VALUE) {
- - if (!isvalidnfs41_open_state_ptr(upcall->state_ref)) {
- - eprintf("upcall_parse: Error accessing "
- - "upcall->state_ref(=0x%p), opcode %u; "
- - "returning ERROR_INVALID_PARAMETER\n",
- - upcall->state_ref, (unsigned int)upcall_upcode);
- - /*
- - * Set |upcall->state_ref| to |INVALID_HANDLE_VALUE|
- - * so that we do not try to dereference it
- - */
- - upcall->state_ref = INVALID_HANDLE_VALUE;
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- -
- - if (upcall->state_ref->ref_count == 0) {
- - eprintf("upcall_parse: upcall->state_ref(=0x%p).ref_count == 0, "
- - "opcode %u; returning ERROR_INVALID_PARAMETER\n",
- - upcall->state_ref, (unsigned int)upcall_upcode);
- - /*
- - * Set |upcall->state_ref| to |INVALID_HANDLE_VALUE|
- - * so that we do not try to dereference it
- - */
- - upcall->state_ref = INVALID_HANDLE_VALUE;
- - status = ERROR_INVALID_PARAMETER;
- - goto out;
- - }
- - }
- -#endif /* NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS */
- -
- if (upcall->state_ref != INVALID_HANDLE_VALUE)
- nfs41_open_state_ref(upcall->state_ref);
- diff --git a/nfs41_build_features.h b/nfs41_build_features.h
- index b15cbdf..38f6372 100644
- --- a/nfs41_build_features.h
- +++ b/nfs41_build_features.h
- @@ -70,15 +70,6 @@
- */
- #define NFS41_DRIVER_STABILITY_HACKS 1
- -/*
- - * NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS - use
- - * horrible hacks to improve stabilty because sometimes we use
- - * |nfs41_open_state| afer a file close in highly parallel
- - * workloads (e.g. building the gcc compiler in parallel).
- - *
- - * #define NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS 1
- - */
- -
- /*
- * NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS - use
- * static, large buffer size for socket receive and send buffers
- --
- 2.45.1
- From 1b3b797da0ad844a289d86b30254215f929da0fc Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Jun 2025 12:37:20 +0200
- Subject: [PATCH 3/4] sys: Avoid integer overflow for upcall timeouts
- Avoid (|DWORD|) integer overflow for upcall timeouts
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.h | 10 +++++-----
- sys/nfs41sys_fsctl.c | 6 +++---
- sys/nfs41sys_readwrite.c | 2 +-
- sys/nfs41sys_updowncall.c | 2 +-
- 4 files changed, 10 insertions(+), 10 deletions(-)
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 349a080..b8b3447 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -148,10 +148,10 @@ extern nfs41_timings getexattr;
- #endif /* ENABLE_TIMINGS */
- #define RELATIVE(wait) (-(wait))
- -#define NANOSECONDS(nanos) (((signed __int64)(nanos)) / 100L)
- -#define MICROSECONDS(micros) (((signed __int64)(micros)) * NANOSECONDS(1000L))
- -#define MILLISECONDS(milli) (((signed __int64)(milli)) * MICROSECONDS(1000L))
- -#define SECONDS(seconds) (((signed __int64)(seconds)) * MILLISECONDS(1000L))
- +#define NANOSECONDS(nanos) (((signed __int64)(nanos)) / 100LL)
- +#define MICROSECONDS(micros) (((signed __int64)(micros)) * NANOSECONDS(1000LL))
- +#define MILLISECONDS(milli) (((signed __int64)(milli)) * MICROSECONDS(1000LL))
- +#define SECONDS(seconds) (((signed __int64)(seconds)) * MILLISECONDS(1000LL))
- typedef enum _nfs41_updowncall_state {
- NFS41_WAITING_FOR_UPCALL,
- @@ -857,7 +857,7 @@ NTSTATUS nfs41_UpcallCreate(
- void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry);
- NTSTATUS nfs41_UpcallWaitForReply(
- IN nfs41_updowncall_entry *entry,
- - IN DWORD secs);
- + IN LONGLONG secs);
- NTSTATUS nfs41_upcall(
- IN PRX_CONTEXT RxContext);
- NTSTATUS nfs41_downcall(
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 6845b89..e80321b 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -618,7 +618,7 @@ NTSTATUS nfs41_DuplicateData(
- (PDUPLICATE_EXTENTS_DATA)FsCtl->pInputBuffer;
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- PFILE_OBJECT srcfo = NULL;
- - DWORD io_delay;
- + LONGLONG io_delay;
- DbgEn();
- @@ -732,8 +732,8 @@ NTSTATUS nfs41_DuplicateData(
- duplicatedatabuffer->ByteCount.QuadPart;
- /* Add extra timeout depending on file size */
- - io_delay = (DWORD)(pVNetRootContext->timeout +
- - EXTRA_TIMEOUT_PER_BYTE(entry->u.DuplicateData.bytecount));
- + io_delay = pVNetRootContext->timeout +
- + EXTRA_TIMEOUT_PER_BYTE(entry->u.DuplicateData.bytecount);
- status = nfs41_UpcallWaitForReply(entry, io_delay);
- if (status) {
- diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
- index cc718df..b60d544 100644
- --- a/sys/nfs41sys_readwrite.c
- +++ b/sys/nfs41sys_readwrite.c
- @@ -240,7 +240,7 @@ NTSTATUS nfs41_Read(
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- - DWORD io_delay;
- + LONGLONG io_delay;
- #ifdef ENABLE_TIMINGS
- LARGE_INTEGER t1, t2;
- t1 = KeQueryPerformanceCounter(NULL);
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index f36b936..29e7ac5 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -503,7 +503,7 @@ void nfs41_UpcallDestroy(nfs41_updowncall_entry *entry)
- NTSTATUS nfs41_UpcallWaitForReply(
- IN nfs41_updowncall_entry *entry,
- - IN DWORD secs)
- + IN LONGLONG secs)
- {
- NTSTATUS status = STATUS_SUCCESS;
- --
- 2.45.1
- From 694f47d87e2bdb1fa9209f1bfa1a5c7b1d6b1d4d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Jun 2025 16:59:34 +0200
- Subject: [PATCH 4/4] README.md,build.vc19,cygwin,docs: Always sign the NFS
- *.exe+*.dll files with the WDK test signature
- Always use signtool.exe to sign the NFS *.exe+*.dll files with the WDK
- test signature, to allow a (Windows Defender) admin to whitelist the
- binaries based on that signature.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- README.md | 4 ++++
- build.vc19/libtirpc/libtirpc.vcxproj | 6 ++++++
- build.vc19/ms-nfs41-client_vs2019.vsconfig | 5 ++++-
- build.vc19/ms-nfs41-client_vs2022.vsconfig | 2 ++
- build.vc19/nfs41_np/nfs41_np.vcxproj | 6 ++++++
- build.vc19/nfs_install/nfs_install.vcxproj | 6 ++++++
- build.vc19/nfs_mount/nfs_mount.vcxproj | 6 ++++++
- build.vc19/nfsd/nfsd.vcxproj | 6 ++++++
- cygwin/Makefile | 14 +++++++-------
- docs/README.xml | 4 ++++
- 10 files changed, 51 insertions(+), 8 deletions(-)
- diff --git a/README.md b/README.md
- index 72144eb..9c3a2de 100644
- --- a/README.md
- +++ b/README.md
- @@ -938,6 +938,8 @@ Source code can be obtained from
- git clone https://github.com/kofemann/ms-nfs41-client.git
- cd ms-nfs41-client
- cd cygwin
- + # get default WDK Test Certificate SHA1 ThumbPrint value for code signing
- + export CERTIFICATE_THUMBPRINT="$(powershell -c 'Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -like "*WDKTestCert*"} | Select-Object -ExpandProperty Thumbprint')"
- make build
- make installdest
- make bintarball
- @@ -952,6 +954,8 @@ Source code can be obtained from
- # ("v142" should remain the default when comitting)
- sed -i -E 's/<PlatformToolset>v142<\/PlatformToolset>/<PlatformToolset>v143<\/PlatformToolset>/g' $(find 'build.vc19' -name \*.vcxproj)
- cd cygwin
- + # get default WDK Test Certificate SHA1 ThumbPrint value for code signing
- + export CERTIFICATE_THUMBPRINT="$(powershell -c 'Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -like "*WDKTestCert*"} | Select-Object -ExpandProperty Thumbprint')"
- make build64
- make installdest64
- make bintarball64
- diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
- index cdf877b..ad91f2a 100644
- --- a/build.vc19/libtirpc/libtirpc.vcxproj
- +++ b/build.vc19/libtirpc/libtirpc.vcxproj
- @@ -1,5 +1,11 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- + <Target Name="Sign" AfterTargets="Build">
- + <SignFile
- + CertificateThumbprint="$(CERTIFICATE_THUMBPRINT)"
- + SigningTarget="$(OutputPath)\libtirpc.dll"
- + TargetFrameworkVersion="v4.5" />
- + </Target>
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- diff --git a/build.vc19/ms-nfs41-client_vs2019.vsconfig b/build.vc19/ms-nfs41-client_vs2019.vsconfig
- index 6941e6e..3d99e86 100755
- --- a/build.vc19/ms-nfs41-client_vs2019.vsconfig
- +++ b/build.vc19/ms-nfs41-client_vs2019.vsconfig
- @@ -13,6 +13,7 @@
- "Microsoft.VisualStudio.Component.JavaScript.TypeScript",
- "Microsoft.Component.MSBuild",
- "Microsoft.VisualStudio.Component.TextTemplating",
- + "Microsoft.VisualStudio.Component.Common.Azure.Tools",
- "Microsoft.VisualStudio.Component.Debugger.JustInTime",
- "Component.Microsoft.VisualStudio.LiveShare",
- "Microsoft.VisualStudio.Component.IntelliCode",
- @@ -52,6 +53,8 @@
- "Microsoft.VisualStudio.Component.VC.MFC.ARM",
- "Microsoft.VisualStudio.Component.VC.MFC.ARM64",
- "Microsoft.VisualStudio.Component.VC.MFC.ARM64EC",
- + "Microsoft.Component.ClickOnce",
- "Microsoft.VisualStudio.Component.Windows10SDK.20348"
- - ]
- + ],
- + "extensions": []
- }
- \ No newline at end of file
- diff --git a/build.vc19/ms-nfs41-client_vs2022.vsconfig b/build.vc19/ms-nfs41-client_vs2022.vsconfig
- index c4078f4..b49e584 100755
- --- a/build.vc19/ms-nfs41-client_vs2022.vsconfig
- +++ b/build.vc19/ms-nfs41-client_vs2022.vsconfig
- @@ -12,6 +12,7 @@
- "Microsoft.Component.MSBuild",
- "Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
- "Microsoft.VisualStudio.Component.TextTemplating",
- + "Microsoft.VisualStudio.Component.Common.Azure.Tools",
- "Microsoft.VisualStudio.Component.NuGet",
- "Microsoft.VisualStudio.Component.Debugger.JustInTime",
- "Microsoft.VisualStudio.Component.IntelliCode",
- @@ -56,6 +57,7 @@
- "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
- "Microsoft.VisualStudio.Component.VC.MFC.ARM",
- "Microsoft.VisualStudio.Component.VC.MFC.ARM64",
- + "Microsoft.Component.ClickOnce",
- "Microsoft.Net.Component.4.6.1.TargetingPack",
- "Component.Microsoft.Windows.DriverKit"
- ],
- diff --git a/build.vc19/nfs41_np/nfs41_np.vcxproj b/build.vc19/nfs41_np/nfs41_np.vcxproj
- index dd6d309..1c486e3 100644
- --- a/build.vc19/nfs41_np/nfs41_np.vcxproj
- +++ b/build.vc19/nfs41_np/nfs41_np.vcxproj
- @@ -1,5 +1,11 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- + <Target Name="Sign" AfterTargets="Build">
- + <SignFile
- + CertificateThumbprint="$(CERTIFICATE_THUMBPRINT)"
- + SigningTarget="$(OutputPath)\nfs41_np.dll"
- + TargetFrameworkVersion="v4.5" />
- + </Target>
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- diff --git a/build.vc19/nfs_install/nfs_install.vcxproj b/build.vc19/nfs_install/nfs_install.vcxproj
- index 46aeda5..2748c7f 100644
- --- a/build.vc19/nfs_install/nfs_install.vcxproj
- +++ b/build.vc19/nfs_install/nfs_install.vcxproj
- @@ -1,5 +1,11 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- + <Target Name="Sign" AfterTargets="Build">
- + <SignFile
- + CertificateThumbprint="$(CERTIFICATE_THUMBPRINT)"
- + SigningTarget="$(OutputPath)\nfs_install.exe"
- + TargetFrameworkVersion="v4.5" />
- + </Target>
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- diff --git a/build.vc19/nfs_mount/nfs_mount.vcxproj b/build.vc19/nfs_mount/nfs_mount.vcxproj
- index 63ccec7..675bb27 100644
- --- a/build.vc19/nfs_mount/nfs_mount.vcxproj
- +++ b/build.vc19/nfs_mount/nfs_mount.vcxproj
- @@ -1,5 +1,11 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- + <Target Name="Sign" AfterTargets="Build">
- + <SignFile
- + CertificateThumbprint="$(CERTIFICATE_THUMBPRINT)"
- + SigningTarget="$(OutputPath)\nfs_mount.exe"
- + TargetFrameworkVersion="v4.5" />
- + </Target>
- <Target Name="generate_git_version_header" BeforeTargets="ClCompile">
- <Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
- <Output TaskParameter="ConsoleOutput" PropertyName="git_version_string" />
- diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
- index d5ae5a1..c33081b 100644
- --- a/build.vc19/nfsd/nfsd.vcxproj
- +++ b/build.vc19/nfsd/nfsd.vcxproj
- @@ -1,5 +1,11 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- + <Target Name="Sign" AfterTargets="Build">
- + <SignFile
- + CertificateThumbprint="$(CERTIFICATE_THUMBPRINT)"
- + SigningTarget="$(OutputPath)\nfsd.exe"
- + TargetFrameworkVersion="v4.5" />
- + </Target>
- <Target Name="generate_git_version_header" BeforeTargets="ClCompile">
- <Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
- <Output TaskParameter="ConsoleOutput" PropertyName="git_version_string" />
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index c390347..f570023 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -31,37 +31,37 @@ $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
- build_64bit_release:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Release -p:Platform=x64
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Release -p:Platform=x64 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_64bit_debug:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=x64
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=x64 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_32bit_release:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Release -p:Platform=x86
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Release -p:Platform=x86 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_32bit_debug:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=x86
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=x86 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_32bit_release_clientutils:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:nfs41_np,nfs_mount -p:Configuration=Release -p:Platform=x86
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:nfs41_np,nfs_mount -p:Configuration=Release -p:Platform=x86 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_32bit_debug_clientutils:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:nfs41_np,nfs_mount -p:Configuration=Debug -p:Platform=x86
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:nfs41_np,nfs_mount -p:Configuration=Debug -p:Platform=x86 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_arm_64bit_debug:
- @printf '#\n# PATH is %q\n#\n' '$(PATH)'
- which MSBuild.exe
- - MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=ARM64
- + MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=ARM64 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
- build_testutils:
- (cd "$(PROJECT_BASEDIR_DIR)/tests/ea" && make all)
- diff --git a/docs/README.xml b/docs/README.xml
- index b292e8f..be0949e 100644
- --- a/docs/README.xml
- +++ b/docs/README.xml
- @@ -918,6 +918,8 @@ export PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019/Commun
- git clone https://github.com/kofemann/ms-nfs41-client.git
- cd ms-nfs41-client
- cd cygwin
- +# get default WDK Test Certificate SHA1 ThumbPrint value for code signing
- +export CERTIFICATE_THUMBPRINT="$(powershell -c 'Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -like "*WDKTestCert*"} | Select-Object -ExpandProperty Thumbprint')"
- make build
- make installdest
- make bintarball</programlisting>
- @@ -932,6 +934,8 @@ cd ms-nfs41-client
- # ("v142" should remain the default when comitting)
- sed -i -E 's/<PlatformToolset>v142<\/PlatformToolset>/<PlatformToolset>v143<\/PlatformToolset>/g' $(find 'build.vc19' -name \*.vcxproj)
- cd cygwin
- +# get default WDK Test Certificate SHA1 ThumbPrint value for code signing
- +export CERTIFICATE_THUMBPRINT="$(powershell -c 'Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -like "*WDKTestCert*"} | Select-Object -ExpandProperty Thumbprint')"
- make build64
- make installdest64
- make bintarball64</programlisting>
- --
- 2.45.1
msnfs41client: Patches for signing the *.(exe|dll) NFS binaries with WDK test signature, cleanup+misc, 2025-06-03
Posted by Anonymous on Tue 3rd Jun 2025 16:28
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.