- From 5b7b4961d95f809a27954d169c70ec58645ef5c3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 10:11:22 +0200
- Subject: [PATCH 1/6] cygwin: Fix drmemory support in msnfs41client
- sys_run_daemon
- Fix DrMemory support in $ bash ./msnfs41client sys_run_daemon #
- (function "nfsclient_system_rundeamon")
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 35 ++++++++++++++++++++++++++-------
- 1 file changed, 28 insertions(+), 7 deletions(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 41a2b4f..744b550 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -279,12 +279,6 @@ function nfsclient_system_rundeamon
- #'--gid' '1616' '--uid' '1616'
- )
- - # run everything as su_system
- - nfsd_args=(
- - 'su_system'
- - "${nfsd_args[@]}"
- - )
- -
- #
- # cdb cheat sheet:
- #
- @@ -304,6 +298,13 @@ function nfsclient_system_rundeamon
- '--args'
- "${nfsd_args[@]}"
- )
- +
- + # run everything as su_system
- + nfsd_args=(
- + 'su_system'
- + "${nfsd_args[@]}"
- + )
- +
- "${nfsd_args[@]}"
- elif false ; then
- export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD");srv*https://msdl.microsoft.com/download/symbols"
- @@ -314,6 +315,13 @@ function nfsclient_system_rundeamon
- "$(cygpath -w "$PWD/${nfsd_args[0]}")"
- "${nfsd_args[@]:1}"
- )
- +
- + # run everything as su_system
- + nfsd_args=(
- + 'su_system'
- + "${nfsd_args[@]}"
- + )
- +
- "${nfsd_args[@]}"
- elif false ; then
- #
- @@ -340,10 +348,18 @@ function nfsclient_system_rundeamon
- "${nfsd_args[@]}"
- '--crtdbgmem' 'none'
- )
- +
- + # run everything as su_system
- + nfsd_args=(
- + 'su_system'
- + "${nfsd_args[@]}"
- + )
- +
- "${nfsd_args[@]}"
- elif false ; then
- typeset -i vsdiagnostics_id=50
- - VSDiagnostics \
- + # run everything as su_system
- + su_system VSDiagnostics \
- start ${vsdiagnostics_id} \
- "/launch:$(cygpath -w "$PWD/nfsd_debug.exe")" \
- "/launchArgs:${nfsd_args[*]:1}" \
- @@ -354,6 +370,11 @@ function nfsclient_system_rundeamon
- "$(which -a 'VSDiagnostics.exe')" \
- "${vsdiagnostics_id}" "$$"
- else
- + # run everything as su_system
- + nfsd_args=(
- + 'su_system'
- + "${nfsd_args[@]}"
- + )
- "${nfsd_args[@]}"
- fi
- --
- 2.43.0
- From 8239b0d14c1500d76817326593805cd0272bf49a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 10:16:28 +0200
- Subject: [PATCH 2/6] sys: Use |nfs41_opcodes opcode| instead of |DWORD| to aid
- WinDBG debugging
- Use |nfs41_opcodes opcode| instead of |DWORD| in
- |struct _updowncall_entry| to aid WinDBG debugging.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 511186c..0378cfe 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -167,7 +167,7 @@ typedef enum _nfs41_updowncall_state {
- typedef struct _updowncall_entry {
- DWORD version;
- LONGLONG xid;
- - DWORD opcode;
- + nfs41_opcodes opcode;
- NTSTATUS status;
- nfs41_updowncall_state state;
- FAST_MUTEX lock;
- --
- 2.43.0
- From 64db3613496e521ba1759bdf7d51c53e9125406a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 10:18:06 +0200
- Subject: [PATCH 3/6] daemon: Fix two DrMemory hits in |decode_readdir_entry()|
- Fix two DrMemory hits in |decode_readdir_entry()|
- Stack traces for the hits:
- ---- snip ----
- Error #30: UNINITIALIZED READ: reading 1 byte(s)
- replace_memmove [D:\a\drmemory\drmemory\drmemory\replace.c:768]
- decode_readdir_entry [ms-nfs41-client\daemon\nfs41_xdr.c:2347]
- decode_readdir_list [ms-nfs41-client\daemon\nfs41_xdr.c:2380]
- decode_op_readdir [ms-nfs41-client\daemon\nfs41_xdr.c:2411]
- nfs_decode_compound [ms-nfs41-client\daemon\nfs41_xdr.c:3688]
- libtirpc.dll!authunix_unwrap [ms-nfs41-client\libtirpc\src\auth_unix.c:391]
- libtirpc.dll!clnt_vc_call [ms-nfs41-client\libtirpc\src\clnt_vc.c:689]
- nfs41_send_compound [ms-nfs41-client\daemon\nfs41_rpc.c:351]
- compound_encode_send_decode [ms-nfs41-client\daemon\nfs41_compound.c:153]
- nfs41_readdir [ms-nfs41-client\daemon\nfs41_ops.c:1113]
- handle_readdir [ms-nfs41-client\daemon\readdir.c:750]
- upcall_handle [ms-nfs41-client\daemon\upcall.c:190]
- nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:176]
- nfsd_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:210]
- ucrtbased.dll!register_onexit_function +0x12f (0x00007ffdbe052d20 <ucrtbased.dll+0xb2d20>)
- KERNEL32.dll!BaseThreadInitThunk
- Error #31: UNINITIALIZED READ: reading 4 byte(s)
- replace_memmove [D:\a\drmemory\drmemory\drmemory\replace.c:757]
- decode_readdir_entry [ms-nfs41-client\daemon\nfs41_xdr.c:2347]
- decode_readdir_list [ms-nfs41-client\daemon\nfs41_xdr.c:2380]
- decode_op_readdir [ms-nfs41-client\daemon\nfs41_xdr.c:2411]
- nfs_decode_compound [ms-nfs41-client\daemon\nfs41_xdr.c:3688]
- libtirpc.dll!authunix_unwrap [ms-nfs41-client\libtirpc\src\auth_unix.c:391]
- libtirpc.dll!clnt_vc_call [ms-nfs41-client\libtirpc\src\clnt_vc.c:689]
- nfs41_send_compound [ms-nfs41-client\daemon\nfs41_rpc.c:351]
- compound_encode_send_decode [ms-nfs41-client\daemon\nfs41_compound.c:153]
- nfs41_readdir [ms-nfs41-client\daemon\nfs41_ops.c:1113]
- handle_readdir [ms-nfs41-client\daemon\readdir.c:750]
- upcall_handle [ms-nfs41-client\daemon\upcall.c:190]
- nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:176]
- nfsd_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:210]
- ucrtbased.dll!register_onexit_function +0x12f (0x00007ffdbe052d20 <ucrtbased.dll+0xb2d20>)
- KERNEL32.dll!BaseThreadInitThunk
- ---- snip ----
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_xdr.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 1a33d95..e617789 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -2304,7 +2304,7 @@ static bool_t decode_readdir_entry(
- unsigned char name[NFS4_OPAQUE_LIMIT];
- unsigned char *nameptr = &name[0];
- uint32_t name_len, entry_len;
- - fattr4 attrs;
- + fattr4 attrs = { 0 };
- /* decode into temporaries so we can determine if there's enough
- * room in the buffer for this entry */
- --
- 2.43.0
- From d36d55f92f5999c92ea1bf57de532a7bd01216d8 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 14:35:35 +0200
- Subject: [PATCH 4/6] daemon: Add |DASSERT_MSG()|+|EASSERT_MSG()| for extra
- assert diagnotics
- Add |DASSERT_MSG()| and |EASSERT_MSG()| macros to print extra
- diagnotics for asserts.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 9 +++++++++
- daemon/daemon_debug.h | 11 +++++++++++
- 2 files changed, 20 insertions(+)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 183a398..8788d2b 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -191,6 +191,15 @@ void logprintf(LPCSTR format, ...)
- }
- }
- +void eprintf_out(LPCSTR format, ...)
- +{
- + va_list args;
- + va_start(args, format);
- + (void)vfprintf(elog_file, format, args);
- + (void)fflush(elog_file);
- + va_end(args);
- +}
- +
- void eprintf(LPCSTR format, ...)
- {
- va_list args;
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index 922367a..e28c43e 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -48,10 +48,20 @@
- if (!(exp)) { \
- eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
- ""#exp"", __FILE__, (long)__LINE__); }
- +#define EASSERT_MSG(exp, msg) \
- + if (!(exp)) { \
- + eprintf("ASSERTION '%s' in '%s'/%ld failed, msg=", \
- + ""#exp"", __FILE__, (long)__LINE__); \
- + eprintf_out msg ; }
- #define DASSERT(exp, level) \
- if (!(exp)) { \
- DPRINTF((level), ("ASSERTION '%s' in '%s'/%ld failed.\n", \
- ""#exp"", __FILE__, (long)__LINE__)); }
- +#define DASSERT_MSG(exp, level, msg) \
- + if (!(exp) && DPRINTF_LEVEL_ENABLED(level)) { \
- + DPRINTF((level), ("ASSERTION '%s' in '%s'/%ld failed, msg=", \
- + ""#exp"", __FILE__, (long)__LINE__)); \
- + dprintf_out msg ; }
- #define DASSERT_IS_VALID_NON_NULL_PTR(exp, level) \
- if (!DEBUG_IS_VALID_NON_NULL_PTR(exp)) { \
- @@ -81,6 +91,7 @@ extern int g_debug_level;
- void set_debug_level(int level);
- void logprintf(LPCSTR format, ...);
- void dprintf_out(LPCSTR format, ...);
- +void eprintf_out(LPCSTR format, ...);
- void eprintf(LPCSTR format, ...);
- void print_windows_access_mask(int on, ACCESS_MASK m);
- --
- 2.43.0
- From 6664e6cc88fd39358ed5a42927caaeee2f8c2104 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 14:37:48 +0200
- Subject: [PATCH 5/6] daemon: Add assert to |sidcache_add()| to test for empty
- names
- Add assertion to |sidcache_add()| to test for empty |win32name|
- strings.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/sid.c | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/daemon/sid.c b/daemon/sid.c
- index 7e3f3d4..ea75bba 100644
- --- a/daemon/sid.c
- +++ b/daemon/sid.c
- @@ -215,6 +215,8 @@ void sidcache_add(sidcache *cache, const char* win32name, PSID value)
- ssize_t freeEntryIndex;
- time_t currentTimestamp;
- + EASSERT(win32name[0] != '\0');
- +
- EnterCriticalSection(&cache->lock);
- currentTimestamp = time(NULL);
- --
- 2.43.0
- From edd7c931bfc817184470d2350ad3144b2e3e75d5 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 3 May 2024 14:40:13 +0200
- Subject: [PATCH 6/6] daemon: Fix DrMemory hit in |handle_setacl()| codepath
- Fix DrMemory hit in |handle_setacl()| codepath, which was
- caused by missing error propagation in |map_nfs4ace_who|().
- DrMemory Stack trace:
- ---- snip ----
- Error #34: UNINITIALIZED READ: reading 1 byte(s)
- replace_strlen [D:\a\drmemory\drmemory\drmemory\replace.c:406]
- encode_file_attrs [ms-nfs41-client\daemon\nfs41_xdr.c:2646]
- encode_op_setattr [ms-nfs41-client\daemon\nfs41_xdr.c:2697]
- nfs_encode_compound [ms-nfs41-client\daemon\nfs41_xdr.c:3632]
- libtirpc.dll!authunix_wrap [ms-nfs41-client\libtirpc\src\auth_unix.c:385]
- libtirpc.dll!clnt_vc_call [ms-nfs41-client\libtirpc\src\clnt_vc.c:575]
- nfs41_send_compound [ms-nfs41-client\daemon\nfs41_rpc.c:351]
- compound_encode_send_decode [ms-nfs41-client\daemon\nfs41_compound.c:153]
- nfs41_setattr [ms-nfs41-client\daemon\nfs41_ops.c:1479]
- handle_setacl [ms-nfs41-client\daemon\acl.c:887]
- upcall_handle [ms-nfs41-client\daemon\upcall.c:190]
- nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:176]
- ---- snip ----
- The patch also adds |EASSERT_MSG()| to immediately report
- empty |info.owner| and |info.owner_group| strings.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 0802374..13cc81b 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -647,6 +647,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- DPRINTF(ACLLVL, ("map_nfs4ace_who: LookupAccountSidA() "
- "returned ERROR_NONE_MAPPED for sidstr='%s'\n",
- sidstr));
- + status = lasterr;
- goto out;
- /* Catch other cases */
- case ERROR_NO_SUCH_USER:
- @@ -655,6 +656,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
- "returned ERROR_NO_SUCH_@(USER|GROUP) for "
- "sidstr='%s'\n",
- sidstr);
- + status = lasterr;
- goto out;
- default:
- eprintf("map_nfs4ace_who: Internal error, "
- @@ -821,6 +823,9 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- info.owner = ownerbuf;
- info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- info.attrmask.count = 2;
- +
- + EASSERT_MSG(info.owner[0] != '\0',
- + ("info.owner='%s'\n", info.owner));
- }
- if (args->query & GROUP_SECURITY_INFORMATION) {
- @@ -840,6 +845,9 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- info.owner_group = groupbuf;
- info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- info.attrmask.count = 2;
- +
- + EASSERT_MSG(info.owner_group[0] != '\0',
- + ("info.owner_group='%s'\n", info.owner_group));
- }
- if (args->query & DACL_SECURITY_INFORMATION) {
- --
- 2.43.0
msnfa41client: Patches for DrMemory hits, assert_msg()+misc, 2024-05-03
Posted by Anonymous on Fri 3rd May 2024 15:27
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.