- From ffa2f9440cccae29fb82039513bb4cecd31e0cfa Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Apr 2024 14:21:40 +0200
- Subject: [PATCH 1/3] libtirpc: |authnone_marshal()| over-unlocks mutex
- |authnone_marshal()| over-unlocks mutex, as detected with the
- Windows application (see
- https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier)
- verifier.
- Stack trace of the over-unlock event:
- ---- snip ----
- vrfcore!VerifierStopMessageEx+0x7f7
- vfbasics!VerifierStopMessage+0x1ad
- vfbasics!AVrfpVerifyCriticalSectionOwner+0x14a
- vfbasics!AVrfpRtlLeaveCriticalSection+0x91
- libtirpc!authnone_marshal(struct __auth * client = 0x000001ca`22ec2980, struct __rpc_xdr * xdrs = 0x000001ca`22ee9ca0, unsigned int * seq = 0x0000009f`794f8354)+0xa8 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\auth_none.c @ 149]
- libtirpc!clnt_vc_call(struct __rpc_client * cl = 0x000001ca`22efc3f0, unsigned int proc = 0, <function> * xdr_args = 0x00007ff7`3093e8f2, void * args_ptr = 0x00000000`00000000, <function> * xdr_results = 0x00007ff7`3093e8f2, void * results_ptr = 0x00000000`00000000, struct timeval timeout = struct timeval)+0x1f0 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c @ 575]
- nfsd!send_null(struct __rpc_client * client = 0x000001ca`22efc3f0)+0x64 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_rpc.c @ 40]
- nfsd!nfs41_rpc_clnt_create(struct __multi_addr4 * addrs = 0x0000009f`794fa130, unsigned int wsize = 0x10042c, unsigned int rsize = 0x100200, unsigned int uid = 0x303e8, unsigned int gid = 0x30201, unsigned int sec_flavor = 0, struct __nfs41_rpc_clnt ** rpc_out = 0x0000009f`794f8ed0)+0x15f [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_rpc.c @ 185]
- nfsd!nfs41_root_mount_addrs(struct __nfs41_root * root = 0x000001ca`22ea3a00, struct __multi_addr4 * addrs = 0x0000009f`794fa130, int is_data = 0n0, unsigned int lease_time = 0, struct __nfs41_client ** client_out = 0x0000009f`794fa238)+0x117 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\namespace.c @ 361]
- nfsd!handle_mount(void * daemon_context = 0x00007ff7`309b4010, struct __nfs41_upcall * upcall = 0x0000009f`794fe600)+0x2bc [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\mount.c @ 127]
- nfsd!upcall_handle(void * daemon_context = 0x00007ff7`309b4010, struct __nfs41_upcall * upcall = 0x0000009f`794fe600)+0x82 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\upcall.c @ 190]
- nfsd!nfsd_worker_thread_main(void * args = 0x00007ff7`309b4010)+0x18b [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c @ 142]
- nfsd!nfsd_thread_main(void * args = 0x00007ff7`309b4010)+0x2b [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c @ 172]
- ucrtbased!thread_start<unsigned int (void * parameter = 0x000001ca`22ea9a30)+0xb0 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
- vfbasics!AVrfpStandardThreadFunction+0x4e
- KERNEL32!BaseThreadInitThunk+0x14
- ntdll!RtlUserThreadStart+0x21
- ---- snip ----
- Reported-by: Dan Shelton <dan.f.shelton@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- libtirpc/src/auth_none.c | 4 ++++
- 1 file changed, 4 insertions(+)
- diff --git a/libtirpc/src/auth_none.c b/libtirpc/src/auth_none.c
- index e2793c6..5e78ea4 100644
- --- a/libtirpc/src/auth_none.c
- +++ b/libtirpc/src/auth_none.c
- @@ -140,12 +140,16 @@ authnone_marshal(AUTH *client, XDR *xdrs, u_int *seq)
- ap = authnone_private;
- if (ap == NULL) {
- +#if 0 /* gisburn: Disabled, causes mutex over-unlock */
- mutex_unlock(&authnone_lock);
- +#endif
- return (FALSE);
- }
- dummy = (*xdrs->x_ops->x_putbytes)(xdrs,
- ap->marshalled_client, ap->mcnt);
- +#if 0 /* gisburn: Disabled, causes mutex over-unlock */
- mutex_unlock(&authnone_lock);
- +#endif
- return (dummy);
- }
- --
- 2.43.0
- From 3964df57a2f3e17e3c667e1d82abe0b485983e8f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Apr 2024 14:36:17 +0200
- Subject: [PATCH 2/3] libtirpc: Use |SRWLOCK| instead of |CRITICAL_SECTION| for
- mutex locks
- Use |SRWLOCK| instead of |CRITICAL_SECTION| for mutex locks, as
- it might be better suited how we use mutex-style locking in
- the libtirpc codebase.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- libtirpc/src/mt_misc.c | 44 +++++++++++++++++++-------------------
- libtirpc/tirpc/reentrant.h | 33 +++++++++++++++++++++++++---
- 2 files changed, 52 insertions(+), 25 deletions(-)
- diff --git a/libtirpc/src/mt_misc.c b/libtirpc/src/mt_misc.c
- index 58d8522..815b590 100644
- --- a/libtirpc/src/mt_misc.c
- +++ b/libtirpc/src/mt_misc.c
- @@ -104,31 +104,31 @@ mutex_t nc_lock;
- #ifdef _WIN32
- /*
- - * Initialize all the mutexes (CriticalSections)
- + * Initialize all the mutexes (CriticalSections or SRWLOCK)
- */
- void multithread_init(void)
- {
- - InitializeCriticalSection(&authdes_lock);
- - InitializeCriticalSection(&authdes_ops_lock);
- - InitializeCriticalSection(&svcauthdesstats_lock);
- - InitializeCriticalSection(&authnone_lock);
- - InitializeCriticalSection(&authsvc_lock);
- - InitializeCriticalSection(&clnt_fd_lock);
- - InitializeCriticalSection(&clntraw_lock);
- - InitializeCriticalSection(&dname_lock);
- - InitializeCriticalSection(&dupreq_lock);
- - InitializeCriticalSection(&keyserv_lock);
- - InitializeCriticalSection(&libnsl_trace_lock);
- - InitializeCriticalSection(&loopnconf_lock);
- - InitializeCriticalSection(&ops_lock);
- - InitializeCriticalSection(&portnum_lock);
- - InitializeCriticalSection(&proglst_lock);
- - InitializeCriticalSection(&rpcsoc_lock);
- - InitializeCriticalSection(&svcraw_lock);
- - InitializeCriticalSection(&tsd_lock);
- - InitializeCriticalSection(&xprtlist_lock);
- - InitializeCriticalSection(&serialize_pkey);
- - InitializeCriticalSection(&nc_lock);
- + mutex_init(&authdes_lock, 0);
- + mutex_init(&authdes_ops_lock, 0);
- + mutex_init(&svcauthdesstats_lock, 0);
- + mutex_init(&authnone_lock, 0);
- + mutex_init(&authsvc_lock, 0);
- + mutex_init(&clnt_fd_lock, 0);
- + mutex_init(&clntraw_lock, 0);
- + mutex_init(&dname_lock, 0);
- + mutex_init(&dupreq_lock, 0);
- + mutex_init(&keyserv_lock, 0);
- + mutex_init(&libnsl_trace_lock, 0);
- + mutex_init(&loopnconf_lock, 0);
- + mutex_init(&ops_lock, 0);
- + mutex_init(&portnum_lock, 0);
- + mutex_init(&proglst_lock, 0);
- + mutex_init(&rpcsoc_lock, 0);
- + mutex_init(&svcraw_lock, 0);
- + mutex_init(&tsd_lock, 0);
- + mutex_init(&xprtlist_lock, 0);
- + mutex_init(&serialize_pkey, 0);
- + mutex_init(&nc_lock, 0);
- }
- #endif
- diff --git a/libtirpc/tirpc/reentrant.h b/libtirpc/tirpc/reentrant.h
- index c81d1a0..a3632d2 100644
- --- a/libtirpc/tirpc/reentrant.h
- +++ b/libtirpc/tirpc/reentrant.h
- @@ -92,6 +92,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -115,25 +116,51 @@
- #include <stdlib.h>
- +/*
- + * |USE_SRWLOCK_FOR_MUTEX| - Use SRWLOCK for |mutex_t| instead of a
- + * |CRITICAL_SECTION|
- + */
- +#define USE_SRWLOCK_FOR_MUTEX 1
- +#ifdef USE_SRWLOCK_FOR_MUTEX
- +#define mutex_t SRWLOCK
- +#else
- #define mutex_t CRITICAL_SECTION
- +#endif /* USE_SRWLOCK_FOR_MUTEX */
- #define cond_t CONDITION_VARIABLE
- #define rwlock_t SRWLOCK
- #define thread_key_t DWORD
- +#ifdef USE_SRWLOCK_FOR_MUTEX
- +#define MUTEX_INITIALIZER SRWLOCK_INIT
- +#else
- #define MUTEX_INITIALIZER -1 /*THIS_NEEDS_HELP*/
- -#define RWLOCK_INITIALIZER -1 /*THIS_NEEDS_HELP*/
- +#endif /* USE_SRWLOCK_FOR_MUTEX */
- +#define RWLOCK_INITIALIZER SRWLOCK_INIT
- +
- +#ifdef USE_SRWLOCK_FOR_MUTEX
- +#define mutex_init(m, a) InitializeSRWLock(m)
- +#define mutex_lock(m) AcquireSRWLockExclusive(m)
- +#define mutex_unlock(m) ReleaseSRWLockExclusive(m)
- +#define mutex_trylock(m) TryAcquireSRWLockExclusive(m)
- +#else
- #define mutex_init(m, a) InitializeCriticalSection(m)
- #define mutex_lock(m) EnterCriticalSection(m)
- #define mutex_unlock(m) LeaveCriticalSection(m)
- #define mutex_trylock(m) TryEnterCriticalSection(m)
- +#endif /* USE_SRWLOCK_FOR_MUTEX */
- #define cond_init(c, a, p) InitializeConditionVariable(c)
- #define cond_signal(m) WakeConditionVariable(m)
- #define cond_broadcast(m) WakeAllConditionVariable(m)
- -#define cond_wait(c, m) SleepConditionVariableCS(c, m, INFINITE)
- -#define cond_wait_timed(c, m, t) SleepConditionVariableCS(c, m, t)
- +#ifdef USE_SRWLOCK_FOR_MUTEX
- +#define cond_wait(c, m) SleepConditionVariableSRW((c), (m), INFINITE, 0)
- +#define cond_wait_timed(c, m, t) SleepConditionVariableSRW((c), (m), (t), 0)
- +#else
- +#define cond_wait(c, m) SleepConditionVariableCS((c), (m), INFINITE)
- +#define cond_wait_timed(c, m, t) SleepConditionVariableCS((c), (m), (t))
- +#endif /* USE_SRWLOCK_FOR_MUTEX */
- #define rwlock_init(l, a) InitializeSRWLock(l)
- #define rwlock_rdlock(l) AcquireSRWLockShared(l)
- --
- 2.43.0
- From 7e319663050b8bdf8a104e0ef88602dff8cbb652 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Apr 2024 15:11:28 +0200
- Subject: [PATCH 3/3] cygwin: bintarball readme: Update required Cygwin version
- from "3.5.1" to "3.5.3"
- Update required Cygwin version in cygwin/README.bintarball.txt from
- "3.5.1" to "3.5.3".
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index bc0209d..c0c2bf3 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -68,7 +68,7 @@ NFSv4.1 client and filesystem driver for Windows 10/11
- # 3. Requirements:
- #
- - Windows 10 or Windows 11
- -- Cygwin 3.5.1 (or 3.6.x-devel)
- +- Cygwin 3.5.3 (or 3.6.x-devel)
- - Packages (required):
- cygwin
- cygwin-devel
- --
- 2.43.0
msnfs41client: libtirpc locking patches+misc, 2024-04-15
Posted by Anonymous on Mon 15th Apr 2024 15:00
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.