- From b850ea10692f8eb7c39b7015b42009c22d4868e1 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 15 Dec 2023 12:39:30 +0100
- Subject: [PATCH 1/8] mount,sys/nfs41_driver: Unaligned mount data can lead to
- mount failure
- Make sure |FILE_FULL_EA_INFORMATION| data is properly longword-aligned,
- (as mandated by
- https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_file_full_ea_information)
- Previously the alignment was only 32bit (|ULONG| for 32bit platform)
- aligned, which lead to random mount failures on 64bit platforms
- (where |ULONG| is a 64bit datatype).
- The patch also adds |IoCheckEaBufferValidity()| to
- |nfs41_MountConfig_ParseOptions()|, to make sure we validate the
- mount data and get a proper error code if they are not valid.
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/options.c | 2 +-
- sys/nfs41_driver.c | 17 +++++++++++++++++
- 2 files changed, 18 insertions(+), 1 deletion(-)
- diff --git a/mount/options.c b/mount/options.c
- index 73649cc..f254d6d 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -86,7 +86,7 @@ static FORCEINLINE ULONG EaBufferSize(
- + NameSize + ValueSize + sizeof(TCHAR);
- /* extended attributes require ULONG alignment;
- * see documentation for IoCheckEaBufferValidity() */
- - return ( (Size + 3) / sizeof(ULONG) ) * sizeof(ULONG);
- + return ( (Size + (sizeof(ULONG)-1)) / sizeof(ULONG) ) * sizeof(ULONG);
- }
- static FORCEINLINE ULONG EaBufferNextOffset(
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index e2919b9..457ce03 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -2760,6 +2760,17 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
- LPWSTR Name;
- size_t NameLen;
- UNICODE_STRING usValue;
- + ULONG error_offset;
- +
- + status = IoCheckEaBufferValidity(EaBuffer, EaLength, &error_offset);
- + if (status) {
- + DbgP("status(=%d)=IoCheckEaBufferValidity"
- + "(eainfo=%p, buflen=%lu, &(error_offset=%d)) failed\n",
- + (int)status, (void *)EaBuffer, EaLength,
- + (int)error_offset);
- + goto out;
- + }
- +
- Option = EaBuffer;
- while (status == STATUS_SUCCESS) {
- DbgP("Option=%p\n", (void *)Option);
- @@ -2857,6 +2868,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
- ((PBYTE)Option + Option->NextEntryOffset);
- }
- +out:
- DbgP("<-- nfs41_MountConfig_ParseOptions, status=%ld\n", (long)status);
- return status;
- }
- @@ -4797,6 +4809,11 @@ NTSTATUS nfs41_SetEaInformation(
- entry->u.SetEa.mode = 0;
- status = IoCheckEaBufferValidity(eainfo, buflen, &error_offset);
- if (status) {
- + DbgP("nfs41_SetEaInformation: "
- + "status(=%d)=IoCheckEaBufferValidity"
- + "(eainfo=%p, buflen=%lu, &(error_offset=%d))\n",
- + (int)status, (void *)eainfo, buflen,
- + (int)error_offset);
- RxFreePool(entry);
- goto out;
- }
- --
- 2.42.1
- From 20f3533e33104728406a7bca517c6d672c1be9f2 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 10:59:10 +0100
- Subject: [PATCH 2/8] sys/nfs41_driver: Fix crash when NFS fs is accessed via
- UNC path before mount
- Fix kernel crash due to an uninitalised mutex when a NFSv4 filesystem
- is accessed via UNC path without being mounted first via
- nfs_mount.exe (UNC paths to a NFSv4 filesystem require that the
- filesystem is mounted via nfs_mount.exe first, so the kernel has
- proper mount options).
- Stack trace from MEMORY.DMP:
- ---- snip ----
- nt!KeBugCheckEx
- nt!KiBugCheckDispatch+0x69
- nt!KiPageFault+0x463
- nt!KeWaitForSingleObject+0x1e1
- nt!ExpAcquireFastMutexContended+0x7a
- nt!ExAcquireFastMutex+0x162
- nfs41_driver!nfs41_CreateVNetRoot+0x356 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\sys\nfs41_driver.c @ 3080]
- nfs41_driver!RxConstructNetRoot+0xdd [base\fs\rdr2\rxce\rxconnct.c @ 1101]
- nfs41_driver!RxFindOrCreateConnections+0x657 [base\fs\rdr2\rxce\rxconnct.c @ 500]
- nfs41_driver!RxConstructVirtualNetRoot+0x72 [base\fs\rdr2\rxce\rxconnct.c @ 1197]
- nfs41_driver!RxFindOrConstructVirtualNetRoot+0x30e [base\fs\rdr2\rxce\rxconnct.c @ 1731]
- nfs41_driver!RxPrefixClaim+0x197 [base\fs\rdr2\rdbss\create.c @ 3037]
- nfs41_driver!RxCommonDevFCBIoCtl+0x92 [base\fs\rdr2\rdbss\ntdevfcb.c @ 498]
- nfs41_driver!RxFinishSrvCallConstruction+0x18f [base\fs\rdr2\rxce\rxconnct.c @ 723]
- nfs41_driver!RxFinishSrvCallConstructionDispatcher+0x84 [base\fs\rdr2\rxce\rxconnct.c @ 805]
- nfs41_driver!RxWorkItemDispatcher+0x13 [base\fs\rdr2\rxce\rxworkq.c @ 1653]
- nfs41_driver!RxpWorkerThreadDispatcher+0xbb [base\fs\rdr2\rxce\rxworkq.c @ 1343]
- nfs41_driver!RxBootstrapWorkerThreadDispatcher+0xb [base\fs\rdr2\rxce\rxworkq.c @ 1469]
- nt!PspSystemThreadStartup+0x55
- nt!KiStartSystemThread+0x28
- ---- snip ----
- This also adds |STATUS_NFS_SHARE_NOT_MOUNTED| (mapped to
- |STATUS_BAD_NETWORK_PATH|) so we always use the same error code for
- this case.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 22 ++++++++++++++++++++--
- 1 file changed, 20 insertions(+), 2 deletions(-)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 457ce03..83aca0b 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -3052,6 +3052,23 @@ NTSTATUS nfs41_CreateVNetRoot(
- /* Codepath for \\server@port\nfs4\path */
- DbgP("Codepath for \\\\server@port\\nfs4\\path\n");
- + /*
- + * STATUS_NFS_SHARE_NOT_MOUNTED - status code for the case
- + * when a NFS filesystem is accessed via UNC path, but no
- + * nfs_mount.exe was done for that filesystem
- + */
- +#define STATUS_NFS_SHARE_NOT_MOUNTED STATUS_BAD_NETWORK_PATH
- + if (!pNetRootContext->mounts_init) {
- + /*
- + * We can only support UNC paths when we got valid
- + * mount options via nfs_mount.exe before this point.
- + */
- + DbgP("pNetRootContext(=%p) not initalised yet\n",
- + pNetRootContext);
- + status = STATUS_NFS_SHARE_NOT_MOUNTED;
- + goto out_free;
- + }
- +
- /*
- * gisburn: Fixme: Originally the code was using the
- * SRV_CALL name (without leading \) as the hostname
- @@ -3074,7 +3091,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- PLIST_ENTRY pEntry;
- - status = STATUS_OBJECT_NAME_NOT_FOUND;
- + status = STATUS_NFS_SHARE_NOT_MOUNTED;
- ExAcquireFastMutex(&pNetRootContext->mountLock);
- pEntry = &pNetRootContext->mounts.head;
- @@ -3098,7 +3115,8 @@ NTSTATUS nfs41_CreateVNetRoot(
- ExReleaseFastMutex(&pNetRootContext->mountLock);
- if (status != STATUS_SUCCESS) {
- - DbgP("No existing mount found\n");
- + DbgP("No existing mount found, "
- + "status==STATUS_NFS_SHARE_NOT_MOUNTED\n");
- goto out_free;
- }
- --
- 2.42.1
- From be737a2627aa659a1b342c5a02578921b167393a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 11:28:49 +0100
- Subject: [PATCH 3/8] mount: nfs_mount.exe should always use debug allocator
- nfs_mount.exe should always use the debug allocator - it is not
- performance sensitive, and it is more important to see leads and
- other memory issues there.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 13 +++++++++++++
- mount/options.c | 3 +++
- 2 files changed, 16 insertions(+)
- diff --git a/mount/mount.c b/mount/mount.c
- index 0d48ec2..b06cac1 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -20,6 +20,9 @@
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- */
- +#define _DEBUG 1
- +
- +#include <crtdbg.h>
- #include <Windows.h>
- #include <tchar.h>
- #include <strsafe.h>
- @@ -96,6 +99,16 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- BOOL bPersistent = FALSE;
- MOUNT_OPTION_LIST Options;
- + int crtsetdbgflags = 0;
- + crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */
- + crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
- + crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
- + (void)_CrtSetDbgFlag(crtsetdbgflags);
- + (void)_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- +
- +
- if (argc == 1) {
- /* list open nfs shares */
- result = EnumMounts(NULL);
- diff --git a/mount/options.c b/mount/options.c
- index f254d6d..53d0e37 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -19,6 +19,9 @@
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- */
- +#define _DEBUG 1
- +
- +#include <crtdbg.h>
- #include <Windows.h>
- #include <tchar.h>
- #include <strsafe.h>
- --
- 2.42.1
- From 38af108c0b47f66bd65d309cf60c46216eb3ab57 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 11:34:48 +0100
- Subject: [PATCH 4/8] daemon: nfs_debug should not open interactive dialogs for
- _CRT_(ERROR|ASSERT)
- nfs_debug.exe should not open interactive Windows dialogs for
- _CRT_ERROR and _CRT_ASSERT issues. Instead they should just be logged
- to the error log.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 99eb468..0097d2e 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -433,7 +433,9 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
- #endif
- (void)_CrtSetDbgFlag(crtsetdbgflags);
- - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- /*
- * Do not fill memory with 0xFE for functions like |strcpy_s()|
- --
- 2.42.1
- From 3a684459fefee5272d6ca0abc5faf37a15ac07f6 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 14:16:03 +0100
- Subject: [PATCH 5/8] daemon: Add --crtdbgmem option to set CRTDBG handling
- Add cmd line option --crtdbgmem to nfsd which accepts the values
- 'allocmem'|'leakcheck'|'delayfree' (OR'ed), or "all" (set all flags),
- 'none' (disable crtdbgmem) or 'default' (use defaults used when
- --crtdbgmem is not set).
- See https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetdbgflag?view=msvc-170
- for a description of the flags.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 141 +++++++++++++++++++++++++++++++-----------
- daemon/nfs41_daemon.h | 3 +
- 2 files changed, 109 insertions(+), 35 deletions(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 0097d2e..1b07301 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -50,6 +50,7 @@ nfs41_daemon_globals nfs41_dg = {
- .default_uid = NFS_USER_NOBODY_UID,
- .default_gid = NFS_GROUP_NOGROUP_GID,
- .num_worker_threads = DEFAULT_NUM_THREADS,
- + .crtdbgmem_flags = NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET,
- };
- @@ -192,6 +193,10 @@ static void PrintUsage()
- "--uid <non-zero value> "
- "--gid <non-zero value> "
- "--numworkerthreads <value-between 16 and %d> "
- +#ifdef _DEBUG
- + "--crtdbgmem <'allocmem'|'leakcheck'|'delayfree', "
- + "'all', 'none' or 'default'> "
- +#endif /* _DEBUG */
- "\n", MAX_NUM_THREADS);
- }
- static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
- @@ -218,6 +223,43 @@ static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
- }
- out->debug_level = _ttoi(argv[i]);
- }
- +#ifdef _DEBUG
- + else if (_tcscmp(argv[i], TEXT("--crtdbgmem")) == 0) {
- + ++i;
- + const TCHAR *memdbgoptions = argv[i];
- + if (i >= argc) {
- + fprintf(stderr, "Missing options\n");
- + PrintUsage();
- + return FALSE;
- + }
- +
- + if (nfs41_dg.crtdbgmem_flags ==
- + NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET)
- + nfs41_dg.crtdbgmem_flags = 0;
- +
- + nfs41_dg.crtdbgmem_flags |=
- + (_tcsstr(memdbgoptions, TEXT("allocmem")) != NULL)?
- + _CRTDBG_ALLOC_MEM_DF:0;
- + nfs41_dg.crtdbgmem_flags |=
- + (_tcsstr(memdbgoptions, TEXT("leakcheck")) != NULL)?
- + _CRTDBG_LEAK_CHECK_DF:0;
- + nfs41_dg.crtdbgmem_flags |=
- + (_tcsstr(memdbgoptions, TEXT("delayfree")) != NULL)?
- + _CRTDBG_DELAY_FREE_MEM_DF:0;
- + nfs41_dg.crtdbgmem_flags |=
- + (_tcsstr(memdbgoptions, TEXT("all")) != NULL)?
- + (_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF|_CRTDBG_DELAY_FREE_MEM_DF):0;
- +
- + if (_tcsstr(memdbgoptions, TEXT("none")) != NULL) {
- + nfs41_dg.crtdbgmem_flags = 0;
- + }
- +
- + if (_tcsstr(memdbgoptions, TEXT("default")) != NULL) {
- + nfs41_dg.crtdbgmem_flags =
- + NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET;
- + }
- + }
- +#endif /* _DEBUG */
- else if (_tcscmp(argv[i], TEXT("--noldap")) == 0) { /* no LDAP */
- out->ldap_enable = FALSE;
- }
- @@ -393,6 +435,69 @@ out:
- return status;
- }
- +
- +static
- +void nfsd_crt_debug_init(void)
- +{
- +#ifdef _DEBUG
- + /* dump memory leaks to stderr on exit; this requires the debug heap,
- + /* available only when built in debug mode under visual studio -cbodley */
- +
- + int crtsetdbgflags = nfs41_dg.crtdbgmem_flags;
- +
- + if (crtsetdbgflags == NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET) {
- + dprintf(0, "crtsetdbgflags not set, using defaults\n");
- + crtsetdbgflags = 0;
- +
- + crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF;
- + crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF;
- + /*
- + * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but
- + * fill memory blocks passed to |free()| with 0xdd. We rely
- + * on that to see 0xdddddddddddddddd-pointers for
- + * use-after-free and catch them in stress testing instead
- + * of having to deal with a core dump.
- + *
- + * This is off by default, as it can lead to memory
- + * exhaustion (e.g. 5GB for $ git clone -b
- + * 'releases/gcc-13.2.0' git://gcc.gnu.org/git/gcc.git on a
- + * NFS filesystem)
- + * ---- snip ----
- + * crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
- + * ---- snip ----
- + */
- + }
- +
- + dprintf(0, "memory debug flags _CRTDBG_(=0x%x)"
- + "{ ALLOC_MEM_DF=%d, LEAK_CHECK_DF=%d, DELAY_FREE_MEM_DF=%d }\n",
- + crtsetdbgflags,
- + ((crtsetdbgflags & _CRTDBG_ALLOC_MEM_DF)?1:0),
- + ((crtsetdbgflags & _CRTDBG_LEAK_CHECK_DF)?1:0),
- + ((crtsetdbgflags & _CRTDBG_DELAY_FREE_MEM_DF)?1:0));
- +
- + (void)_CrtSetDbgFlag(crtsetdbgflags);
- +
- + /*
- + * Do not fill memory with 0xFE for functions like |strcpy_s()|
- + * etc, as it causes bad performance. We have drmemory to find
- + * issues like that instead
- + */
- + (void)_CrtSetDebugFillThreshold(0);
- +
- + (void)_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- + (void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- +
- + (void)_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- + (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- + (void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- +
- + if (crtsetdbgflags & _CRTDBG_LEAK_CHECK_DF) {
- + dprintf(1, "debug mode. dumping memory leaks to stderr on exit.\n");
- + }
- +#endif /* _DEBUG */
- +}
- +
- #ifdef STANDALONE_NFSD
- void __cdecl _tmain(int argc, TCHAR *argv[])
- #else
- @@ -412,43 +517,9 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- exit(1);
- set_debug_level(cmd_args.debug_level);
- open_log_files();
- + nfsd_crt_debug_init();
- sidcache_init();
- -#ifdef _DEBUG
- - /* dump memory leaks to stderr on exit; this requires the debug heap,
- - /* available only when built in debug mode under visual studio -cbodley */
- -
- - int crtsetdbgflags = 0;
- - crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */
- - crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
- -/* Disabled for now, git clone ... gcc.git does not work with it */
- -#ifdef DISABLED_FOR_NOW
- - /*
- - * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but fill
- - * memory blocks passed to |free()| with 0xdd. We rely on that to
- - * see 0xdddddddddddddddd-pointers for use-after-free and catch
- - * them in stress testing instead of having to deal with a core
- - * dump
- - */
- - crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
- -#endif
- - (void)_CrtSetDbgFlag(crtsetdbgflags);
- - (void)_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- - (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- - (void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- -
- - /*
- - * Do not fill memory with 0xFE for functions like |strcpy_s()|
- - * etc, as it causes bad performance. We have drmemory to find
- - * issues like that instead
- - */
- - (void)_CrtSetDebugFillThreshold(0);
- -#pragma warning (push)
- -#pragma warning (disable : 4306) /* conversion from 'int' to '_HFILE' of greater size */
- - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- -#pragma warning (pop)
- - dprintf(1, "debug mode. dumping memory leaks to stderr on exit.\n");
- -#endif
- /* acquire and store in global memory current dns domain name.
- * needed for acls */
- if (getdomainname()) {
- diff --git a/daemon/nfs41_daemon.h b/daemon/nfs41_daemon.h
- index 2023fdc..f89b281 100644
- --- a/daemon/nfs41_daemon.h
- +++ b/daemon/nfs41_daemon.h
- @@ -35,6 +35,9 @@ typedef struct __nfs41_daemon_globals {
- int default_uid;
- int default_gid;
- ssize_t num_worker_threads;
- + int crtdbgmem_flags;
- } nfs41_daemon_globals;
- +#define NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET (-1)
- +
- #endif /* !__NFS41_DAEMON_H_ */
- --
- 2.42.1
- From f27a0117921770d2ebbe2928360aae7d19a1944f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 14:30:23 +0100
- Subject: [PATCH 6/8] cygwin/devel/msnfs41client.bash: Use --crtdbgmem none for
- drmemory
- Use nfsd_debug option --crtdbgmem none for drmemory debug mode.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 130b508..0b4c703 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -191,6 +191,7 @@ function nfsclient_rundeamon
- '-preload_symbols'
- '--'
- "${nfsd_args[@]}"
- + '--crtdbgmem' 'none'
- )
- "${nfsd_args[@]}"
- else
- @@ -271,6 +272,7 @@ function nfsclient_system_rundeamon
- '-preload_symbols'
- '--'
- "${nfsd_args[@]}"
- + '--crtdbgmem' 'none'
- )
- "${nfsd_args[@]}"
- else
- --
- 2.42.1
- From 324df5036106de017e644cb8bd78666657babb5b Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 14:39:12 +0100
- Subject: [PATCH 7/8] mount,Cygwin/Makefile: Fix "Release" build failure+enable
- Release build
- Fix build failure in "Release" build caused by commit for
- "mount: nfs_mount.exe should always use debug allocator",
- and enable the "Release" build by default to avoid future issues
- like this.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 2 +-
- mount/mount.c | 1 -
- mount/options.c | 2 --
- 3 files changed, 1 insertion(+), 4 deletions(-)
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index 8eb25fa..e9207f6 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -29,8 +29,8 @@ $(VS_BUILD_DIR)/nfsd.exe \
- build:
- @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=Debug -p:Platform=x64
- - #MSBuild.exe $(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln -t:Build -p:Configuration=Debug -p:Platform=x64
- (cd tests/winfsinfo1 && make all)
- #
- diff --git a/mount/mount.c b/mount/mount.c
- index b06cac1..f8372e6 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -20,7 +20,6 @@
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- */
- -#define _DEBUG 1
- #include <crtdbg.h>
- #include <Windows.h>
- diff --git a/mount/options.c b/mount/options.c
- index 53d0e37..53be68c 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -19,8 +19,6 @@
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- */
- -#define _DEBUG 1
- -
- #include <crtdbg.h>
- #include <Windows.h>
- #include <tchar.h>
- --
- 2.42.1
- From 51c7447599ff4d89667ffea1d87068ce8b940887 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 18 Dec 2023 16:16:50 +0100
- Subject: [PATCH 8/8] cygwin/devel/msnfs41client.bash: Enable "SegmentHeap"
- allocator
- Enable "SegmentHeap" allocator in registry for nfs_mount.exe,
- nfsd.exe and nfsd_debug.exe for testing.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 8 ++++++++
- 1 file changed, 8 insertions(+)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 0b4c703..def9735 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -93,6 +93,14 @@ function nfsclient_install
- # (see https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
- regtool -i set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled' 1
- + # use the Win10 "SegmentHeap" (see https://www.blackhat.com/docs/us-16/materials/us-16-Yason-Windows-10-Segment-Heap-Internals.pdf)
- + regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
- + regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd_debug.exe/FrontEndHeapDebugOptions' 0x08
- + regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe'
- + regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe/FrontEndHeapDebugOptions' 0x08
- + regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
- + regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe/FrontEndHeapDebugOptions' 0x08
- +
- # make sure we can load the kernel driver
- # (does not work with SecureBoot)
- bcdedit /set testsigning on
- --
- 2.42.1
msnfs41client: Patches for UNC crashes+mem allocator debug options, 2023-12-18
Posted by Anonymous on Mon 18th Dec 2023 15:29
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.