- From 13d33576cb0e85a6f8226aed9a1ef556239d8a70 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 10:20:25 +0200
- Subject: [PATCH 1/7] cygwin: Add ucrtbase*.dll to DrMemory uninit blocklist
- cygwin: Add ucrtbased.dll and ucrtbase.dll to DrMemory uninit
- blocklist, as it permamently reports uninit accesses for vprintf&co
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 744b550..cf4c516 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -223,7 +223,7 @@ function nfsclient_rundeamon
- '-brief'
- '-no_follow_children'
- '-lib_blocklist_frames' '1'
- - '-check_uninit_blocklist' 'MSWSOCK,WS2_32'
- + '-check_uninit_blocklist' 'MSWSOCK,WS2_32,ucrtbased.dll,ucrtbase.dll'
- '-malloc_callstacks'
- '-delay_frees' '16384'
- '-delay_frees_maxsz' $((64*1024*1024))
- @@ -334,7 +334,7 @@ function nfsclient_system_rundeamon
- '-brief'
- '-no_follow_children'
- '-lib_blocklist_frames' '1'
- - '-check_uninit_blocklist' 'MSWSOCK,WS2_32'
- + '-check_uninit_blocklist' 'MSWSOCK,WS2_32,ucrtbased.dll,ucrtbase.dll'
- '-malloc_callstacks'
- '-delay_frees' '16384'
- '-delay_frees_maxsz' $((64*1024*1024))
- --
- 2.43.0
- From 91fa94f0aca0bed215942cd8892f64baf733f84a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 10:22:35 +0200
- Subject: [PATCH 2/7] daemon: Fix DrMemory hit in |handle_mount()|
- DrMemory Stack trace:
- ---- snip ----
- Error 1: UNINITIALIZED READ: reading 4 byte(s)
- 0 replace_memmove [D:\a\drmemory\drmemory\drmemory\replace.c:757]
- 1 nfs41_rpc_clnt_create [ms-nfs41-client\daemon\nfs41_rpc.c:219]
- 2 nfs41_root_mount_addrs [ms-nfs41-client\daemon\namespace.c:361]
- 3 handle_mount [ms-nfs41-client\daemon\mount.c:146]
- 4 upcall_handle [ms-nfs41-client\daemon\upcall.c:190]
- 5 nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:178]
- 6 nfsd_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:212]
- 7 ucrtbased.dll!register_onexit_function+0x12f (0x00007fffff442d20 <ucrtbased.dll+0xb2d20>)
- 8 KERNEL32.dll!BaseThreadInitThunk
- ---- snip ----
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/mount.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/daemon/mount.c b/daemon/mount.c
- index a0fe2f7..ff46a5d 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -65,7 +65,7 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- char *s;
- int port = 0;
- nfs41_abs_path path;
- - multi_addr4 addrs;
- + multi_addr4 addrs = { 0 };
- nfs41_root *root;
- nfs41_client *client;
- nfs41_path_fh file;
- --
- 2.43.0
- From 33cc5df5d6c5ee3ac01478e615d8fa79aad8a87d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 12:13:35 +0200
- Subject: [PATCH 3/7] daemon: Keep a valid thread impersonation token in
- |nfs41_upcall|
- Keep a valid thread impersonation token in |nfs41_upcall|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/mount.c | 10 +---------
- daemon/nfs41_daemon.c | 26 ++++++++++++++++++++------
- daemon/upcall.h | 14 ++++++++++++++
- 3 files changed, 35 insertions(+), 15 deletions(-)
- diff --git a/daemon/mount.c b/daemon/mount.c
- index ff46a5d..ea59368 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -72,23 +72,15 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- EASSERT(args->hostport != NULL);
- -#define MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN 1
- -
- -#ifdef MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN
- logprintf("mount(hostport='%s', path='%s') request\n",
- args->hostport?args->hostport:"<NULL>",
- args->path?args->path:"<NULL>");
- - HANDLE tok;
- - if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &tok)) {
- - (void)CloseHandle(tok);
- - }
- - else {
- + if (upcall->currentthread_token == INVALID_HANDLE_VALUE){
- eprintf("handle_mount: Thread has no impersonation token\n");
- status = ERROR_NO_IMPERSONATION_TOKEN;
- goto out;
- }
- -#endif /* MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN */
- if ((args->path == NULL) || (strlen(args->path) == 0)) {
- DPRINTF(1, ("handle_mount: empty mount root\n"));
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 207fbdc..56a960e 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -67,12 +67,12 @@ typedef struct _nfs41_process_thread {
- uint32_t tid;
- } nfs41_process_thread;
- -static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *puid, gid_t *pgid)
- +static int map_current_user_to_ids(nfs41_idmapper *idmapper,
- + HANDLE impersonation_tok, uid_t *puid, gid_t *pgid)
- {
- char username[UNLEN+1];
- char pgroupname[GNLEN+1];
- int status = NO_ERROR;
- - HANDLE impersonation_tok = GetCurrentThreadEffectiveToken();
- if (!get_token_user_name(impersonation_tok, username)) {
- status = GetLastError();
- @@ -159,11 +159,21 @@ static unsigned int nfsd_worker_thread_main(void *args)
- goto write_downcall;
- }
- + if (!OpenThreadToken(GetCurrentThread(),
- + TOKEN_QUERY/*|TOKEN_IMPERSONATE*/, FALSE,
- + &upcall.currentthread_token)) {
- + upcall.currentthread_token = INVALID_HANDLE_VALUE;
- + DPRINTF(0, ("nfsd_worker_thread_main: "
- + "OpenThreadToken() failed, lasterr=%d.\n",
- + (int)GetLastError()));
- + }
- +
- /*
- - * Map current username to uid/gid
- + * Map current { user, primary_group } to { uid, gid }
- * Each thread can handle a different user
- */
- status = map_current_user_to_ids(nfs41dg->idmapper,
- + upcall.currentthread_token,
- &upcall.uid, &upcall.gid);
- if (status) {
- upcall.status = status;
- @@ -184,11 +194,15 @@ write_downcall:
- upcall_marshall(&upcall, inbuf, (uint32_t)inbuf_len, (uint32_t*)&outbuf_len);
- - DPRINTF(2, ("making a downcall: outbuf_len %ld\n\n", outbuf_len));
- /*
- - * Note: Caller impersonation ends here - nfs41_driver.sys
- - * |IOCTL_NFS41_WRITE| calls |SeStopImpersonatingClient()|
- + * Note: Caller impersonation ends with |IOCTL_NFS41_WRITE| -
- + * nfs41_driver.sys |IOCTL_NFS41_WRITE| calls
- + * |SeStopImpersonatingClient()|
- */
- + (void)CloseHandle(upcall.currentthread_token);
- + upcall.currentthread_token = INVALID_HANDLE_VALUE;
- +
- + DPRINTF(2, ("making a downcall: outbuf_len %ld\n\n", outbuf_len));
- status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE,
- inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL);
- if (!status) {
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index 681300d..8df1899 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.h
- @@ -202,6 +202,20 @@ typedef struct __nfs41_upcall {
- uint32_t last_error;
- upcall_args args;
- + /*
- + * |currentthread_token| - (Impersonation) thread token and
- + * local uid/gid of the user we are impersonating
- + * This should be |INVALID_HANDLE_VALUE| if the thread
- + * has no impersonation token, as we use this for access
- + * checking.
- + */
- + HANDLE currentthread_token;
- + /*
- + * Local uid/gid of impersonated user/primary_group
- + * The NFSv4 server might use different uid/gid, and our
- + * idmapper is resposible for the
- + * local_uid/local_gid <--> owner/owner_group translation
- + */
- uid_t uid;
- gid_t gid;
- --
- 2.43.0
- From 596f0f0345fd17aae6284cfc9d4247da3cb91b1a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 12:57:37 +0200
- Subject: [PATCH 4/7] daemon: Minor debug code cleanup (|const|+macros)
- Minor debug code cleanup, |const|ify arguments, add macros
- and avoid calling into functions which do noting at a given
- debug level.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 12 ++-
- daemon/daemon_debug.c | 217 ++++++++++++++++++++--------------------
- daemon/daemon_debug.h | 6 +-
- daemon/nfs41_compound.c | 10 +-
- daemon/nfs41_ops.c | 5 +-
- daemon/upcall.c | 4 +-
- 6 files changed, 134 insertions(+), 120 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 13cc81b..b7250fa 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -719,8 +719,10 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- SID_NAME_USE who_sid_type = 0;
- DPRINTF(ACLLVL, ("NON-NULL dacl with %d ACEs\n", acl->AceCount));
- - print_hexbuf_no_asci(ACLLVL, (unsigned char *)"ACL\n",
- - (unsigned char *)acl, acl->AclSize);
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_hexbuf_no_asci("ACL\n",
- + (const unsigned char *)acl, acl->AclSize);
- + }
- nfs4_acl->count = acl->AceCount;
- nfs4_acl->aces = calloc(nfs4_acl->count, sizeof(nfsace4));
- if (nfs4_acl->aces == NULL) {
- @@ -736,8 +738,10 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- goto out_free;
- }
- tmp_pointer = (PBYTE)ace;
- - print_hexbuf_no_asci(ACLLVL, (unsigned char *)"ACE\n",
- - (unsigned char *)ace, ace->AceSize);
- + if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
- + print_hexbuf_no_asci("ACE\n",
- + (const unsigned char *)ace, ace->AceSize);
- + }
- DPRINTF(ACLLVL, ("ACE TYPE: %x\n", ace->AceType));
- if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE)
- nfs4_acl->aces[i].acetype = ACE4_ACCESS_ALLOWED_ACE_TYPE;
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 8788d2b..790a7f7 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -210,10 +210,9 @@ void eprintf(LPCSTR format, ...)
- va_end(args);
- }
- -void print_hexbuf(int level, unsigned char *title, unsigned char *buf, int len)
- +void print_hexbuf(const char *title, const unsigned char *buf, int len)
- {
- int j, k;
- - if (level > g_debug_level) return;
- fprintf(dlog_file, "%s", title);
- for(j = 0, k = 0; j < len; j++, k++) {
- fprintf(dlog_file, "%02x '%c' ", buf[j], isascii(buf[j])? buf[j]:' ');
- @@ -224,10 +223,9 @@ void print_hexbuf(int level, unsigned char *title, unsigned char *buf, int len)
- fprintf(dlog_file, "\n");
- }
- -void print_hexbuf_no_asci(int level, unsigned char *title, unsigned char *buf, int len)
- +void print_hexbuf_no_asci(const char *title, const unsigned char *buf, int len)
- {
- int j, k;
- - if (level > g_debug_level) return;
- fprintf(dlog_file, "%s", title);
- for(j = 0, k = 0; j < len; j++, k++) {
- fprintf(dlog_file, "%02x ", buf[j]);
- @@ -340,7 +338,7 @@ void print_share_mode(int level, DWORD mode)
- fprintf(dlog_file, "\n");
- }
- -void print_file_id_both_dir_info(int level, FILE_ID_BOTH_DIR_INFO *pboth_dir_info)
- +void print_file_id_both_dir_info(int level, const FILE_ID_BOTH_DIR_INFO *pboth_dir_info)
- {
- /* printf %zd is for |size_t| */
- @@ -415,91 +413,93 @@ void print_sid(const char *label, PSID sid)
- const char* opcode2string(DWORD opcode)
- {
- switch(opcode) {
- - case NFS41_SHUTDOWN: return "NFS41_SHUTDOWN";
- - case NFS41_MOUNT: return "NFS41_MOUNT";
- - case NFS41_UNMOUNT: return "NFS41_UNMOUNT";
- - case NFS41_OPEN: return "NFS41_OPEN";
- - case NFS41_CLOSE: return "NFS41_CLOSE";
- - case NFS41_READ: return "NFS41_READ";
- - case NFS41_WRITE: return "NFS41_WRITE";
- - case NFS41_LOCK: return "NFS41_LOCK";
- - case NFS41_UNLOCK: return "NFS41_UNLOCK";
- - case NFS41_DIR_QUERY: return "NFS41_DIR_QUERY";
- - case NFS41_FILE_QUERY: return "NFS41_FILE_QUERY";
- - case NFS41_FILE_SET: return "NFS41_FILE_SET";
- - case NFS41_EA_SET: return "NFS41_EA_SET";
- - case NFS41_EA_GET: return "NFS41_EA_GET";
- - case NFS41_SYMLINK: return "NFS41_SYMLINK";
- - case NFS41_VOLUME_QUERY: return "NFS41_VOLUME_QUERY";
- - case NFS41_ACL_QUERY: return "NFS41_ACL_QUERY";
- - case NFS41_ACL_SET: return "NFS41_ACL_SET";
- - default: return "UNKNOWN";
- +#define NFSOPCODE_TO_STRLITERAL(e) case e: return #e;
- + NFSOPCODE_TO_STRLITERAL(NFS41_SHUTDOWN)
- + NFSOPCODE_TO_STRLITERAL(NFS41_MOUNT)
- + NFSOPCODE_TO_STRLITERAL(NFS41_UNMOUNT)
- + NFSOPCODE_TO_STRLITERAL(NFS41_OPEN)
- + NFSOPCODE_TO_STRLITERAL(NFS41_CLOSE)
- + NFSOPCODE_TO_STRLITERAL(NFS41_READ)
- + NFSOPCODE_TO_STRLITERAL(NFS41_WRITE)
- + NFSOPCODE_TO_STRLITERAL(NFS41_LOCK)
- + NFSOPCODE_TO_STRLITERAL(NFS41_UNLOCK)
- + NFSOPCODE_TO_STRLITERAL(NFS41_DIR_QUERY)
- + NFSOPCODE_TO_STRLITERAL(NFS41_FILE_QUERY)
- + NFSOPCODE_TO_STRLITERAL(NFS41_FILE_SET)
- + NFSOPCODE_TO_STRLITERAL(NFS41_EA_SET)
- + NFSOPCODE_TO_STRLITERAL(NFS41_EA_GET)
- + NFSOPCODE_TO_STRLITERAL(NFS41_SYMLINK)
- + NFSOPCODE_TO_STRLITERAL(NFS41_VOLUME_QUERY)
- + NFSOPCODE_TO_STRLITERAL(NFS41_ACL_QUERY)
- + NFSOPCODE_TO_STRLITERAL(NFS41_ACL_SET)
- }
- + return "<unknown NFS41 opcode>";
- }
- const char* nfs_opnum_to_string(int opnum)
- {
- switch (opnum)
- {
- - case OP_ACCESS: return "ACCESS";
- - case OP_CLOSE: return "CLOSE";
- - case OP_COMMIT: return "COMMIT";
- - case OP_CREATE: return "CREATE";
- - case OP_DELEGPURGE: return "DELEGPURGE";
- - case OP_DELEGRETURN: return "DELEGRETURN";
- - case OP_GETATTR: return "GETATTR";
- - case OP_GETFH: return "GETFH";
- - case OP_LINK: return "LINK";
- - case OP_LOCK: return "LOCK";
- - case OP_LOCKT: return "LOCKT";
- - case OP_LOCKU: return "LOCKU";
- - case OP_LOOKUP: return "LOOKUP";
- - case OP_LOOKUPP: return "LOOKUPP";
- - case OP_NVERIFY: return "NVERIFY";
- - case OP_OPEN: return "OPEN";
- - case OP_OPENATTR: return "OPENATTR";
- - case OP_OPEN_CONFIRM: return "OPEN_CONFIRM";
- - case OP_OPEN_DOWNGRADE: return "OPEN_DOWNGRADE";
- - case OP_PUTFH: return "PUTFH";
- - case OP_PUTPUBFH: return "PUTPUBFH";
- - case OP_PUTROOTFH: return "PUTROOTFH";
- - case OP_READ: return "READ";
- - case OP_READDIR: return "READDIR";
- - case OP_READLINK: return "READLINK";
- - case OP_REMOVE: return "REMOVE";
- - case OP_RENAME: return "RENAME";
- - case OP_RENEW: return "RENEW";
- - case OP_RESTOREFH: return "RESTOREFH";
- - case OP_SAVEFH: return "SAVEFH";
- - case OP_SECINFO: return "SECINFO";
- - case OP_SETATTR: return "SETATTR";
- - case OP_SETCLIENTID: return "SETCLIENTID";
- - case OP_SETCLIENTID_CONFIRM: return "SETCLIENTID_CONFIRM";
- - case OP_VERIFY: return "VERIFY";
- - case OP_WRITE: return "WRITE";
- - case OP_RELEASE_LOCKOWNER: return "RELEASE_LOCKOWNER";
- - case OP_BACKCHANNEL_CTL: return "BACKCHANNEL_CTL";
- - case OP_BIND_CONN_TO_SESSION: return "BIND_CONN_TO_SESSION";
- - case OP_EXCHANGE_ID: return "EXCHANGE_ID";
- - case OP_CREATE_SESSION: return "CREATE_SESSION";
- - case OP_DESTROY_SESSION: return "DESTROY_SESSION";
- - case OP_FREE_STATEID: return "FREE_STATEID";
- - case OP_GET_DIR_DELEGATION: return "GET_DIR_DELEGATION";
- - case OP_GETDEVICEINFO: return "GETDEVICEINFO";
- - case OP_GETDEVICELIST: return "GETDEVICELIST";
- - case OP_LAYOUTCOMMIT: return "LAYOUTCOMMIT";
- - case OP_LAYOUTGET: return "LAYOUTGET";
- - case OP_LAYOUTRETURN: return "LAYOUTRETURN";
- - case OP_SECINFO_NO_NAME: return "SECINFO_NO_NAME";
- - case OP_SEQUENCE: return "SEQUENCE";
- - case OP_SET_SSV: return "SET_SSV";
- - case OP_TEST_STATEID: return "TEST_STATEID";
- - case OP_WANT_DELEGATION: return "WANT_DELEGATION";
- - case OP_DESTROY_CLIENTID: return "DESTROY_CLIENTID";
- - case OP_RECLAIM_COMPLETE: return "RECLAIM_COMPLETE";
- - case OP_ILLEGAL: return "ILLEGAL";
- - default: return "invalid nfs opnum";
- +#define NFSOPNUM_TO_STRLITERAL(e) case e: return #e;
- + NFSOPNUM_TO_STRLITERAL(OP_ACCESS)
- + NFSOPNUM_TO_STRLITERAL(OP_CLOSE)
- + NFSOPNUM_TO_STRLITERAL(OP_COMMIT)
- + NFSOPNUM_TO_STRLITERAL(OP_CREATE)
- + NFSOPNUM_TO_STRLITERAL(OP_DELEGPURGE)
- + NFSOPNUM_TO_STRLITERAL(OP_DELEGRETURN)
- + NFSOPNUM_TO_STRLITERAL(OP_GETATTR)
- + NFSOPNUM_TO_STRLITERAL(OP_GETFH)
- + NFSOPNUM_TO_STRLITERAL(OP_LINK)
- + NFSOPNUM_TO_STRLITERAL(OP_LOCK)
- + NFSOPNUM_TO_STRLITERAL(OP_LOCKT)
- + NFSOPNUM_TO_STRLITERAL(OP_LOCKU)
- + NFSOPNUM_TO_STRLITERAL(OP_LOOKUP)
- + NFSOPNUM_TO_STRLITERAL(OP_LOOKUPP)
- + NFSOPNUM_TO_STRLITERAL(OP_NVERIFY)
- + NFSOPNUM_TO_STRLITERAL(OP_OPEN)
- + NFSOPNUM_TO_STRLITERAL(OP_OPENATTR)
- + NFSOPNUM_TO_STRLITERAL(OP_OPEN_CONFIRM)
- + NFSOPNUM_TO_STRLITERAL(OP_OPEN_DOWNGRADE)
- + NFSOPNUM_TO_STRLITERAL(OP_PUTFH)
- + NFSOPNUM_TO_STRLITERAL(OP_PUTPUBFH)
- + NFSOPNUM_TO_STRLITERAL(OP_PUTROOTFH)
- + NFSOPNUM_TO_STRLITERAL(OP_READ)
- + NFSOPNUM_TO_STRLITERAL(OP_READDIR)
- + NFSOPNUM_TO_STRLITERAL(OP_READLINK)
- + NFSOPNUM_TO_STRLITERAL(OP_REMOVE)
- + NFSOPNUM_TO_STRLITERAL(OP_RENAME)
- + NFSOPNUM_TO_STRLITERAL(OP_RENEW)
- + NFSOPNUM_TO_STRLITERAL(OP_RESTOREFH)
- + NFSOPNUM_TO_STRLITERAL(OP_SAVEFH)
- + NFSOPNUM_TO_STRLITERAL(OP_SECINFO)
- + NFSOPNUM_TO_STRLITERAL(OP_SETATTR)
- + NFSOPNUM_TO_STRLITERAL(OP_SETCLIENTID)
- + NFSOPNUM_TO_STRLITERAL(OP_SETCLIENTID_CONFIRM)
- + NFSOPNUM_TO_STRLITERAL(OP_VERIFY)
- + NFSOPNUM_TO_STRLITERAL(OP_WRITE)
- + NFSOPNUM_TO_STRLITERAL(OP_RELEASE_LOCKOWNER)
- + NFSOPNUM_TO_STRLITERAL(OP_BACKCHANNEL_CTL)
- + NFSOPNUM_TO_STRLITERAL(OP_BIND_CONN_TO_SESSION)
- + NFSOPNUM_TO_STRLITERAL(OP_EXCHANGE_ID)
- + NFSOPNUM_TO_STRLITERAL(OP_CREATE_SESSION)
- + NFSOPNUM_TO_STRLITERAL(OP_DESTROY_SESSION)
- + NFSOPNUM_TO_STRLITERAL(OP_FREE_STATEID)
- + NFSOPNUM_TO_STRLITERAL(OP_GET_DIR_DELEGATION)
- + NFSOPNUM_TO_STRLITERAL(OP_GETDEVICEINFO)
- + NFSOPNUM_TO_STRLITERAL(OP_GETDEVICELIST)
- + NFSOPNUM_TO_STRLITERAL(OP_LAYOUTCOMMIT)
- + NFSOPNUM_TO_STRLITERAL(OP_LAYOUTGET)
- + NFSOPNUM_TO_STRLITERAL(OP_LAYOUTRETURN)
- + NFSOPNUM_TO_STRLITERAL(OP_SECINFO_NO_NAME)
- + NFSOPNUM_TO_STRLITERAL(OP_SEQUENCE)
- + NFSOPNUM_TO_STRLITERAL(OP_SET_SSV)
- + NFSOPNUM_TO_STRLITERAL(OP_TEST_STATEID)
- + NFSOPNUM_TO_STRLITERAL(OP_WANT_DELEGATION)
- + NFSOPNUM_TO_STRLITERAL(OP_DESTROY_CLIENTID)
- + NFSOPNUM_TO_STRLITERAL(OP_RECLAIM_COMPLETE)
- + NFSOPNUM_TO_STRLITERAL(OP_ILLEGAL)
- }
- + return "<invalid nfs opnum>";
- }
- const char* nfs_error_string(int status)
- @@ -620,39 +620,41 @@ const char* nfs_error_string(int status)
- NFSERR_TO_STRLITERAL(NFS4ERR_OFFLOAD_NO_REQS)
- NFSERR_TO_STRLITERAL(NFS4ERR_NOXATTR)
- NFSERR_TO_STRLITERAL(NFS4ERR_XATTR2BIG)
- - default: return "invalid nfs error code";
- }
- + return "<invalid NFS4ERR_* code>";
- }
- const char* rpc_error_string(int status)
- {
- switch (status)
- {
- - case RPC_CANTENCODEARGS: return "RPC_CANTENCODEARGS";
- - case RPC_CANTDECODERES: return "RPC_CANTDECODERES";
- - case RPC_CANTSEND: return "RPC_CANTSEND";
- - case RPC_CANTRECV: return "RPC_CANTRECV";
- - case RPC_TIMEDOUT: return "RPC_TIMEDOUT";
- - case RPC_INTR: return "RPC_INTR";
- - case RPC_UDERROR: return "RPC_UDERROR";
- - case RPC_VERSMISMATCH: return "RPC_VERSMISMATCH";
- - case RPC_AUTHERROR: return "RPC_AUTHERROR";
- - case RPC_PROGUNAVAIL: return "RPC_PROGUNAVAIL";
- - case RPC_PROGVERSMISMATCH: return "RPC_PROGVERSMISMATCH";
- - case RPC_PROCUNAVAIL: return "RPC_PROCUNAVAIL";
- - case RPC_CANTDECODEARGS: return "RPC_CANTDECODEARGS";
- - case RPC_SYSTEMERROR: return "RPC_SYSTEMERROR";
- - default: return "invalid rpc error code";
- +#define RPCERR_TO_STRLITERAL(e) case e: return #e;
- + RPCERR_TO_STRLITERAL(RPC_CANTENCODEARGS)
- + RPCERR_TO_STRLITERAL(RPC_CANTDECODERES)
- + RPCERR_TO_STRLITERAL(RPC_CANTSEND)
- + RPCERR_TO_STRLITERAL(RPC_CANTRECV)
- + RPCERR_TO_STRLITERAL(RPC_TIMEDOUT)
- + RPCERR_TO_STRLITERAL(RPC_INTR)
- + RPCERR_TO_STRLITERAL(RPC_UDERROR)
- + RPCERR_TO_STRLITERAL(RPC_VERSMISMATCH)
- + RPCERR_TO_STRLITERAL(RPC_AUTHERROR)
- + RPCERR_TO_STRLITERAL(RPC_PROGUNAVAIL)
- + RPCERR_TO_STRLITERAL(RPC_PROGVERSMISMATCH)
- + RPCERR_TO_STRLITERAL(RPC_PROCUNAVAIL)
- + RPCERR_TO_STRLITERAL(RPC_CANTDECODEARGS)
- + RPCERR_TO_STRLITERAL(RPC_SYSTEMERROR)
- }
- + return "<invalid RPC_* error code>";
- }
- const char* gssauth_string(int type) {
- switch(type) {
- - case RPCSEC_SSPI_SVC_NONE: return "RPCSEC_SSPI_SVC_NONE";
- - case RPCSEC_SSPI_SVC_INTEGRITY: return "RPCSEC_SSPI_SVC_INTEGRITY";
- - case RPCSEC_SSPI_SVC_PRIVACY: return "RPCSEC_SSPI_SVC_PRIVACY";
- - default: return "invalid gss auth type";
- +#define RPCSEC_TO_STRLITERAL(e) case e: return #e;
- + RPCSEC_TO_STRLITERAL(RPCSEC_SSPI_SVC_NONE)
- + RPCSEC_TO_STRLITERAL(RPCSEC_SSPI_SVC_INTEGRITY)
- + RPCSEC_TO_STRLITERAL(RPCSEC_SSPI_SVC_PRIVACY)
- }
- + return "<invalid RPCSEC_SSPI_* gss auth type>";
- }
- void print_condwait_status(int level, int status)
- @@ -703,13 +705,14 @@ void print_sr_status_flags(int level, int flags)
- const char* secflavorop2name(DWORD sec_flavor)
- {
- switch(sec_flavor) {
- - case RPCSEC_AUTH_SYS: return "AUTH_SYS";
- - case RPCSEC_AUTHGSS_KRB5: return "AUTHGSS_KRB5";
- - case RPCSEC_AUTHGSS_KRB5I: return "AUTHGSS_KRB5I";
- - case RPCSEC_AUTHGSS_KRB5P: return "AUTHGSS_KRB5P";
- +#define RPCSEC_AUTH_TO_STRLITERAL(e) case e: return #e;
- + RPCSEC_AUTH_TO_STRLITERAL(RPCSEC_AUTH_SYS)
- + RPCSEC_AUTH_TO_STRLITERAL(RPCSEC_AUTHGSS_KRB5)
- + RPCSEC_AUTH_TO_STRLITERAL(RPCSEC_AUTHGSS_KRB5I)
- + RPCSEC_AUTH_TO_STRLITERAL(RPCSEC_AUTHGSS_KRB5P)
- }
- - return "UNKNOWN FLAVOR";
- + return "<Unknown RPCSEC_AUTH* flavour>";
- }
- void print_windows_access_mask(int on, ACCESS_MASK m)
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index e28c43e..11ec977 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -96,13 +96,13 @@ void eprintf(LPCSTR format, ...);
- void print_windows_access_mask(int on, ACCESS_MASK m);
- void print_nfs_access_mask(int on, int m);
- -void print_hexbuf_no_asci(int on, unsigned char *title, unsigned char *buf, int len);
- -void print_hexbuf(int level, unsigned char *title, unsigned char *buf, int len);
- +void print_hexbuf_no_asci(const char *title, const unsigned char *buf, int len);
- +void print_hexbuf(const char *title, const unsigned char *buf, int len);
- void print_create_attributes(int level, DWORD create_opts);
- void print_disposition(int level, DWORD disposition);
- void print_access_mask(int level, DWORD access_mask);
- void print_share_mode(int level, DWORD mode);
- -void print_file_id_both_dir_info(int level, FILE_ID_BOTH_DIR_INFO *p);
- +void print_file_id_both_dir_info(int level, const FILE_ID_BOTH_DIR_INFO *p);
- void print_sid(const char *label, PSID sid);
- const char* opcode2string(DWORD opcode);
- const char* nfs_opnum_to_string(int opnum);
- diff --git a/daemon/nfs41_compound.c b/daemon/nfs41_compound.c
- index 5d98d97..b137437 100644
- --- a/daemon/nfs41_compound.c
- +++ b/daemon/nfs41_compound.c
- @@ -169,10 +169,12 @@ retry:
- if (memcmp(seq->sr_resok4.sr_sessionid, args->sa_sessionid,
- NFS4_SESSIONID_SIZE)) {
- eprintf("[session] sr_sessionid != sa_sessionid\n");
- - print_hexbuf(1, (unsigned char *)"sr_sessionid",
- - seq->sr_resok4.sr_sessionid, NFS4_SESSIONID_SIZE);
- - print_hexbuf(1, (unsigned char *)"sa_sessionid",
- - args->sa_sessionid, NFS4_SESSIONID_SIZE);
- + if (DPRINTF_LEVEL_ENABLED(1)) {
- + print_hexbuf("sr_sessionid",
- + seq->sr_resok4.sr_sessionid, NFS4_SESSIONID_SIZE);
- + print_hexbuf("sa_sessionid",
- + args->sa_sessionid, NFS4_SESSIONID_SIZE);
- + }
- status = NFS4ERR_IO;
- goto out_free_slot;
- }
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 74d6e99..4699c16 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -196,7 +196,10 @@ int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_
- session->fore_chan_attrs.ca_maxoperations);
- }
- - print_hexbuf(1, (unsigned char *)"session id: ", session->session_id, NFS4_SESSIONID_SIZE);
- + if (DPRINTF_LEVEL_ENABLED(1)) {
- + print_hexbuf("session id: ",
- + session->session_id, NFS4_SESSIONID_SIZE);
- + }
- // check that csa_sequence is same as csr_sequence
- if (reply.csr_sequence != clnt->seq_id) {
- eprintf("ERROR: CREATE_SESSION: csa_sequence %d != "
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index 126e740..099159b 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -89,7 +89,9 @@ int upcall_parse(
- }
- DPRINTF(2, ("received %d bytes upcall data: processing upcall\n", length));
- - print_hexbuf(4, (unsigned char *)"upcall buffer: ", buffer, length);
- + if (DPRINTF_LEVEL_ENABLED(4)) {
- + print_hexbuf("upcall buffer: ", buffer, length);
- + }
- /* parse common elements */
- status = safe_read(&buffer, &length, &version, sizeof(uint32_t));
- --
- 2.43.0
- From c341658a522be84b66ab17b9ab231cfc63b40488 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 13:35:46 +0200
- Subject: [PATCH 5/7] daemon,sys: Add NULL opcode to |_nfs41_opcodes|
- Add NULL opcode to |_nfs41_opcodes|, to avoid calling |NFS41_MOUNT|
- in case of zero'ed memory.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 3 ++-
- daemon/daemon_debug.h | 3 ++-
- daemon/upcall.c | 12 +++++++++---
- daemon/upcall.h | 4 +++-
- sys/nfs41_driver.h | 4 +++-
- 5 files changed, 19 insertions(+), 7 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 790a7f7..b912b9f 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -410,10 +410,11 @@ void print_sid(const char *label, PSID sid)
- }
- }
- -const char* opcode2string(DWORD opcode)
- +const char* opcode2string(nfs41_opcodes opcode)
- {
- switch(opcode) {
- #define NFSOPCODE_TO_STRLITERAL(e) case e: return #e;
- + NFSOPCODE_TO_STRLITERAL(NFS41_INVALID_OPCODE0)
- NFSOPCODE_TO_STRLITERAL(NFS41_SHUTDOWN)
- NFSOPCODE_TO_STRLITERAL(NFS41_MOUNT)
- NFSOPCODE_TO_STRLITERAL(NFS41_UNMOUNT)
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index 11ec977..73dd1b1 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -104,7 +104,8 @@ void print_access_mask(int level, DWORD access_mask);
- void print_share_mode(int level, DWORD mode);
- void print_file_id_both_dir_info(int level, const FILE_ID_BOTH_DIR_INFO *p);
- void print_sid(const char *label, PSID sid);
- -const char* opcode2string(DWORD opcode);
- +typedef enum _nfs41_opcodes nfs41_opcodes;
- +const char* opcode2string(nfs41_opcodes opcode);
- const char* nfs_opnum_to_string(int opnum);
- const char* nfs_error_string(int status);
- const char* rpc_error_string(int status);
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index 099159b..9245cf7 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -48,7 +48,9 @@ extern const nfs41_upcall_op nfs41_op_volume;
- extern const nfs41_upcall_op nfs41_op_getacl;
- extern const nfs41_upcall_op nfs41_op_setacl;
- +/* |_nfs41_opcodes| and |g_upcall_op_table| must be in sync! */
- static const nfs41_upcall_op *g_upcall_op_table[] = {
- + NULL,
- &nfs41_op_mount,
- &nfs41_op_unmount,
- &nfs41_op_open,
- @@ -98,8 +100,11 @@ int upcall_parse(
- if (status) goto out;
- status = safe_read(&buffer, &length, &upcall->xid, sizeof(uint64_t));
- if (status) goto out;
- - status = safe_read(&buffer, &length, &upcall->opcode, sizeof(uint32_t));
- + /* |sizeof(enum)| might not be the same as |sizeof(uint32_t)| */
- + uint32_t upcall_upcode = 0;
- + status = safe_read(&buffer, &length, &upcall_upcode, sizeof(uint32_t));
- if (status) goto out;
- + upcall->opcode = upcall_upcode;
- status = safe_read(&buffer, &length, &upcall->root_ref, sizeof(HANDLE));
- if (status) goto out;
- status = safe_read(&buffer, &length, &upcall->state_ref, sizeof(HANDLE));
- @@ -113,9 +118,10 @@ int upcall_parse(
- upcall->status = status = NFSD_VERSION_MISMATCH;
- goto out;
- }
- - if (upcall->opcode >= g_upcall_op_table_size) {
- + if (upcall_upcode >= g_upcall_op_table_size) {
- status = ERROR_NOT_SUPPORTED;
- - eprintf("unrecognized upcall opcode %d!\n", upcall->opcode);
- + eprintf("upcall_parse: unrecognized upcall opcode %d!\n",
- + upcall->opcode);
- goto out;
- }
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index 8df1899..ab93317 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.h
- @@ -195,9 +195,11 @@ typedef union __upcall_args {
- setacl_upcall_args setacl;
- } upcall_args;
- +typedef enum _nfs41_opcodes nfs41_opcodes;
- +
- typedef struct __nfs41_upcall {
- uint64_t xid;
- - uint32_t opcode;
- + nfs41_opcodes opcode;
- uint32_t status;
- uint32_t last_error;
- upcall_args args;
- diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
- index 39cee5a..68c9cad 100644
- --- a/sys/nfs41_driver.h
- +++ b/sys/nfs41_driver.h
- @@ -60,7 +60,9 @@
- */
- #define NFS41_SYS_MAX_PATH_LEN 4096
- +/* |_nfs41_opcodes| and |g_upcall_op_table| must be in sync! */
- typedef enum _nfs41_opcodes {
- + NFS41_INVALID_OPCODE0,
- NFS41_MOUNT,
- NFS41_UNMOUNT,
- NFS41_OPEN,
- @@ -79,7 +81,7 @@ typedef enum _nfs41_opcodes {
- NFS41_ACL_QUERY,
- NFS41_ACL_SET,
- NFS41_SHUTDOWN,
- - INVALID_OPCODE
- + NFS41_INVALID_OPCODE1
- } nfs41_opcodes;
- enum rpcsec_flavors {
- --
- 2.43.0
- From 492c492e7bf6e8af35bdddb2ad3814566140b8ab Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 15:03:27 +0200
- Subject: [PATCH 6/7] daemon, sys: Add |NFS41_FILE_QUERY_TIME_BASED_COHERENCY|
- for debugging
- Add |NFS41_FILE_QUERY_TIME_BASED_COHERENCY| for debugging of
- time based coherency cache management.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 1 +
- daemon/getattr.c | 28 +++++++++++++++++++++++-----
- daemon/upcall.c | 3 ++-
- sys/nfs41_driver.c | 5 ++++-
- sys/nfs41_driver.h | 1 +
- 5 files changed, 31 insertions(+), 7 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index b912b9f..f7e144e 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -426,6 +426,7 @@ const char* opcode2string(nfs41_opcodes opcode)
- NFSOPCODE_TO_STRLITERAL(NFS41_UNLOCK)
- NFSOPCODE_TO_STRLITERAL(NFS41_DIR_QUERY)
- NFSOPCODE_TO_STRLITERAL(NFS41_FILE_QUERY)
- + NFSOPCODE_TO_STRLITERAL(NFS41_FILE_QUERY_TIME_BASED_COHERENCY)
- NFSOPCODE_TO_STRLITERAL(NFS41_FILE_SET)
- NFSOPCODE_TO_STRLITERAL(NFS41_EA_SET)
- NFSOPCODE_TO_STRLITERAL(NFS41_EA_GET)
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index 675ac54..9320527 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -27,6 +27,7 @@
- #include "nfs41_build_features.h"
- #include "nfs41_ops.h"
- #include "name_cache.h"
- +#include "nfs41_driver.h" /* only for |NFS41_FILE_QUERY*| */
- #include "upcall.h"
- #include "daemon_debug.h"
- @@ -57,7 +58,7 @@ int nfs41_cached_getattr(
- return status;
- }
- -/* NFS41_FILE_QUERY */
- +/* NFS41_FILE_QUERY, NFS41_FILE_QUERY_TIME_BASED_COHERENCY */
- static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- {
- int status;
- @@ -65,32 +66,47 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- #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->state_ref(=0x%p) was "
- - "recently deleted\n", 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: Error accessing "
- + 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;
- }
- @@ -102,7 +118,9 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- - DPRINTF(1, ("parsing NFS41_FILE_QUERY: info_class=%d buf_len=%d file='%.*s'\n",
- + DPRINTF(1, ("parsing '%s': "
- + "info_class=%d buf_len=%d file='%.*s'\n",
- + opcode2string(upcall->opcode),
- args->query_class, args->buf_len, upcall->state_ref->path.len,
- upcall->state_ref->path.path));
- out:
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index 9245cf7..54cef78 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -60,7 +60,8 @@ static const nfs41_upcall_op *g_upcall_op_table[] = {
- &nfs41_op_lock,
- &nfs41_op_unlock,
- &nfs41_op_readdir,
- - &nfs41_op_getattr,
- + &nfs41_op_getattr, /* NFS41_FILE_QUERY */
- + &nfs41_op_getattr, /* NFS41_FILE_QUERY_TIME_BASED_COHERENCY */
- &nfs41_op_setattr,
- &nfs41_op_getexattr,
- &nfs41_op_setexattr,
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index e7714c5..5341263 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -1464,6 +1464,7 @@ NTSTATUS handle_upcall(
- status = marshal_nfs41_dirquery(entry, pbOut, cbOut, len);
- break;
- case NFS41_FILE_QUERY:
- + case NFS41_FILE_QUERY_TIME_BASED_COHERENCY:
- status = marshal_nfs41_filequery(entry, pbOut, cbOut, len);
- break;
- case NFS41_FILE_SET:
- @@ -2064,6 +2065,7 @@ NTSTATUS nfs41_downcall(
- status = unmarshal_nfs41_dirquery(cur, &buf);
- break;
- case NFS41_FILE_QUERY:
- + case NFS41_FILE_QUERY_TIME_BASED_COHERENCY:
- unmarshal_nfs41_getattr(cur, &buf);
- break;
- case NFS41_EA_GET:
- @@ -7154,7 +7156,8 @@ VOID fcbopen_main(PVOID ctx)
- pNetRootContext =
- NFS41GetNetRootExtension(cur->fcb->pNetRoot);
- /* place an upcall for this srv_open */
- - status = nfs41_UpcallCreate(NFS41_FILE_QUERY,
- + status = nfs41_UpcallCreate(
- + NFS41_FILE_QUERY_TIME_BASED_COHERENCY,
- &cur->nfs41_fobx->sec_ctx, cur->session,
- cur->nfs41_fobx->nfs41_open_state,
- pNetRootContext->nfs41d_version, NULL, &entry);
- diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
- index 68c9cad..147aa19 100644
- --- a/sys/nfs41_driver.h
- +++ b/sys/nfs41_driver.h
- @@ -73,6 +73,7 @@ typedef enum _nfs41_opcodes {
- NFS41_UNLOCK,
- NFS41_DIR_QUERY,
- NFS41_FILE_QUERY,
- + NFS41_FILE_QUERY_TIME_BASED_COHERENCY,
- NFS41_FILE_SET,
- NFS41_EA_GET,
- NFS41_EA_SET,
- --
- 2.43.0
- From be9712a5c96ba3c648c2bcf1b02b13b6b771b1f6 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 14 May 2024 16:08:35 +0200
- Subject: [PATCH 7/7] daemon: Add SID functions
- |unixuser_sid2uid()|+|unixgroup_sid2gid()|
- Add SID utility functions |unixuser_sid2uid()| and
- |unixgroup_sid2gid()| to get an |uid_t|/|gid_t| from an
- UnixUser+X/UnixGroup+X SID.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/sid.c | 43 +++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 43 insertions(+)
- diff --git a/daemon/sid.c b/daemon/sid.c
- index 20db96b..94128d9 100644
- --- a/daemon/sid.c
- +++ b/daemon/sid.c
- @@ -22,6 +22,7 @@
- #include <Windows.h>
- #include <stdio.h>
- +#include <stdbool.h>
- #include <time.h>
- #include <strsafe.h>
- #include <sddl.h>
- @@ -173,6 +174,48 @@ BOOL allocate_unixgroup_sid(unsigned long gid, PSID *pSid)
- gid, GetLastError()));
- return FALSE;
- }
- +
- +bool unixuser_sid2uid(PSID psid, uid_t *puid)
- +{
- + if (!psid)
- + return false;
- +
- + PSID_IDENTIFIER_AUTHORITY psia = GetSidIdentifierAuthority(psid);
- + if ((*GetSidSubAuthorityCount(psid) == 2) &&
- + (psia->Value[0] == 0) &&
- + (psia->Value[1] == 0) &&
- + (psia->Value[2] == 0) &&
- + (psia->Value[3] == 0) &&
- + (psia->Value[4] == 0) &&
- + (psia->Value[5] == 22) &&
- + (*GetSidSubAuthority(psid, 0) == 1)) {
- + *puid = *GetSidSubAuthority(psid, 1);
- + return true;
- + }
- +
- + return false;
- +}
- +
- +bool unixgroup_sid2gid(PSID psid, gid_t *pgid)
- +{
- + if (!psid)
- + return false;
- +
- + PSID_IDENTIFIER_AUTHORITY psia = GetSidIdentifierAuthority(psid);
- + if ((*GetSidSubAuthorityCount(psid) == 2) &&
- + (psia->Value[0] == 0) &&
- + (psia->Value[1] == 0) &&
- + (psia->Value[2] == 0) &&
- + (psia->Value[3] == 0) &&
- + (psia->Value[4] == 0) &&
- + (psia->Value[5] == 22) &&
- + (*GetSidSubAuthority(psid, 0) == 2)) {
- + *pgid = *GetSidSubAuthority(psid, 1);
- + return true;
- + }
- +
- + return false;
- +}
- #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
- --
- 2.43.0
msnfs41client: Patches for DrMemory hits, time-based cache management debugging, cleanup+misc, 2024-05-14
Posted by Anonymous on Tue 14th May 2024 15:31
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.