- From ca59549c2228c2fa88eddac580c1bb8998ffc8e3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 21 Jun 2025 15:28:09 +0200
- Subject: [PATCH 01/11] daemon: Fix DrMemory hit in |nfs41_open()|
- Fix DrMemory hit in |nfs41_open()|.
- Stack trace looks like this:
- ---- snip ----
- 0 nfs41_open [ms-nfs41-client\daemon\nfs41_ops.c:470]
- 1 nfs41_delegation_to_open [ms-nfs41-client\daemon\delegation.c:589]
- 2 delegation_return [ms-nfs41-client\daemon\delegation.c:306]
- 3 nfs41_delegation_return [ms-nfs41-client\daemon\delegation.c:667]
- 4 handle_nfs41_setattr_basicinfo [ms-nfs41-client\daemon\setattr.c:160]
- 5 handle_setattr [ms-nfs41-client\daemon\setattr.c:661]
- 6 upcall_parse [ms-nfs41-client\daemon\upcall.c:179]
- 7 upcall_handle [ms-nfs41-client\daemon\upcall.c:205]
- 8 nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:209]
- ---- snip ----
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/delegation.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/daemon/delegation.c b/daemon/delegation.c
- index efd2b20..3b29797 100644
- --- a/daemon/delegation.c
- +++ b/daemon/delegation.c
- @@ -547,7 +547,7 @@ int nfs41_delegation_to_open(
- IN nfs41_open_state *open,
- IN bool_t try_recovery)
- {
- - open_delegation4 ignore;
- + open_delegation4 ignore = { 0 };
- open_claim4 claim;
- stateid4 open_stateid = { 0 };
- stateid_arg deleg_stateid;
- --
- 2.45.1
- From 1fa53ff17bc3e2454199ecf8a874da7616e65363 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 23 Jun 2025 13:59:30 +0200
- Subject: [PATCH 02/11] daemon: Define maximum number of ACE entries in an ACL
- as |NFS41_ACL_MAX_ACE_ENTRIES|
- Define maximum number of ACE entries in an ACL as
- |NFS41_ACL_MAX_ACE_ENTRIES|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_const.h | 3 +++
- daemon/nfs41_xdr.c | 9 ++++++---
- 2 files changed, 9 insertions(+), 3 deletions(-)
- diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
- index aa0fc29..ee9674a 100644
- --- a/daemon/nfs41_const.h
- +++ b/daemon/nfs41_const.h
- @@ -48,6 +48,9 @@
- */
- #define NFS4_FATTR4_OWNER_LIMIT (256)
- +/* Maximum number of ACLs per file/dir */
- +#define NFS41_ACL_MAX_ACE_ENTRIES (32)
- +
- #define NFS41_MAX_SERVER_CACHE 1024
- #define NFS41_MAX_RPC_REQS 128
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index bb77072..4ccbeaa 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -325,7 +325,8 @@ static bool_t xdr_nfsdacl41(
- return FALSE;
- return xdr_array(xdr, (char**)&acl->aces, &acl->count,
- - 32, sizeof(nfsace4), (xdrproc_t)xdr_nfsace4);
- + NFS41_ACL_MAX_ACE_ENTRIES, sizeof(nfsace4),
- + (xdrproc_t)xdr_nfsace4);
- }
- static bool_t xdr_nfsacl41(
- @@ -333,7 +334,8 @@ static bool_t xdr_nfsacl41(
- nfsacl41 *acl)
- {
- return xdr_array(xdr, (char**)&acl->aces, &acl->count,
- - 32, sizeof(nfsace4), (xdrproc_t)xdr_nfsace4);
- + NFS41_ACL_MAX_ACE_ENTRIES, sizeof(nfsace4),
- + (xdrproc_t)xdr_nfsace4);
- }
- void nfsacl41_free(nfsacl41 *acl)
- @@ -1778,7 +1780,8 @@ static bool_t decode_file_attrs(
- if (attrs->attrmask.arr[0] & FATTR4_WORD0_ACL) {
- nfsacl41 *acl = info->acl;
- if (!xdr_array(xdr, (char**)&acl->aces, &acl->count,
- - 32, sizeof(nfsace4), (xdrproc_t)xdr_nfsace4))
- + NFS41_ACL_MAX_ACE_ENTRIES, sizeof(nfsace4),
- + (xdrproc_t)xdr_nfsace4))
- return FALSE;
- }
- if (attrs->attrmask.arr[0] & FATTR4_WORD0_ACLSUPPORT) {
- --
- 2.45.1
- From 9c55054c162498f139ca5f6485cd1b7a81b63dde Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 23 Jun 2025 14:01:18 +0200
- Subject: [PATCH 03/11] daemon: Increase SID cache size to 128 to deal with
- larger ACLs
- Increase SID cache size to 128 to deal with larger ACLs
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/sid.c | 13 ++++++++++++-
- 1 file changed, 12 insertions(+), 1 deletion(-)
- diff --git a/daemon/sid.c b/daemon/sid.c
- index 945f744..9e0e356 100644
- --- a/daemon/sid.c
- +++ b/daemon/sid.c
- @@ -220,9 +220,20 @@ bool unixgroup_sid2gid(PSID psid, gid_t *pgid)
- #ifdef NFS41_DRIVER_SID_CACHE
- -#define SIDCACHE_SIZE 20
- +/*
- + * |SIDCACHE_SIZE| - size of SID cache
- + * We should at least use the maximum size of ACL entries plus { owner,
- + * owner_group, other, nobody, world, ... } entries multiplied by two to
- + * make sure two concurrent icacls queries cannot trash the whole cache
- + */
- +#define SIDCACHE_SIZE 128
- #define SIDCACHE_TTL 600
- +/* Safety/performance checks */
- +#if SIDCACHE_SIZE < ((NFS41_ACL_MAX_ACE_ENTRIES+8)*2)
- +#error SIDCACHE_SIZE should be at least ((NFS41_ACL_MAX_ACE_ENTRIES+8)*2)
- +#endif
- +
- typedef struct _sidcache_entry
- {
- #define SIDCACHE_ENTRY_NAME_SIZE (UTF8_UNLEN + 1)
- --
- 2.45.1
- From a9193dbc3f2e3e33ef5d4f7c061579f77e100f52 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 24 Jun 2025 12:45:02 +0200
- Subject: [PATCH 04/11] libtirpc: Expose libtirpc.dll allocator as external API
- Expose libtirpc.dll allocator as external API.
- Windows allows DLLs and EXE to have their own memory allocators
- (instances, e.g. multiple CRT allocators using all the same process
- heap, or another heap=, so we have to provide an API to allocate
- and free memofy using this allocator.
- Otherwise we get memory corruption if we allocate with one memory
- allocator (instance), but free with a different one.
- FIXME: This should really be part of the libtirpc API
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- libtirpc/libtirpc/libtirpc.def | 2 ++
- libtirpc/src/wintirpc.c | 20 ++++++++++++++++++++
- libtirpc/tirpc/wintirpc.h | 2 ++
- 3 files changed, 24 insertions(+)
- diff --git a/libtirpc/libtirpc/libtirpc.def b/libtirpc/libtirpc/libtirpc.def
- index 6509655..ba5ce3e 100644
- --- a/libtirpc/libtirpc/libtirpc.def
- +++ b/libtirpc/libtirpc/libtirpc.def
- @@ -46,6 +46,8 @@ svcudp_create
- taddr2uaddr
- tsd_key_delete
- uaddr2taddr
- +wintirpc_mem_alloc
- +wintirpc_mem_free
- xdr_array
- xdr_authunix_parms
- xdr_bool
- diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
- index 836c321..d9f4d4c 100644
- --- a/libtirpc/src/wintirpc.c
- +++ b/libtirpc/src/wintirpc.c
- @@ -536,6 +536,26 @@ void wintirpc_warnx(const char *format, ...)
- va_end(args);
- }
- +/*
- + * Windows allows DLLs and EXE to have their own memory allocators, so we
- + * have to provide an API to allocate and free memofy using this allocator
- + *
- + * FIXME: This should really be part of the libtirpc API
- + */
- +void *wintirpc_mem_alloc(size_t s)
- +{
- + /*
- + * |mem_alloc()| is a macro which uses |calloc()|, therefore we
- + * use |malloc()| here directly
- + */
- + return malloc(s);
- +}
- +
- +void wintirpc_mem_free(void *p)
- +{
- + free(p);
- +}
- +
- int tirpc_exit(void)
- {
- if (init == 0 || --init > 0)
- diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
- index 878bed0..1649764 100644
- --- a/libtirpc/tirpc/wintirpc.h
- +++ b/libtirpc/tirpc/wintirpc.h
- @@ -163,6 +163,8 @@ int wintirpc_setsockopt(int socket, int level, int option_name,
- void wintirpc_setnfsclientsockopts(int sock);
- void wintirpc_syslog(int prio, const char *format, ...);
- void wintirpc_warnx(const char *format, ...);
- +void *wintirpc_mem_alloc(size_t s);
- +void wintirpc_mem_free(void *p);
- void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
- void wintirpc_unregister_osfhandle(SOCKET handle);
- void wintirpc_unregister_osf_fd(int fd);
- --
- 2.45.1
- From 82e27f050fcfc6243a30229329d3fb8f3c1fb230 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 10:23:18 +0200
- Subject: [PATCH 05/11] daemon: Provide |bitmap_or()| function to OR two
- |bitmap4| variables
- Provide |bitmap_or()| function to logically OR two |bitmap4|
- variables.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.h | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
- diff --git a/daemon/util.h b/daemon/util.h
- index 011d411..058da7b 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -132,6 +132,18 @@ static __inline void bitmap_intersect(
- }
- dst->count = min(dst->count, count);
- }
- +static __inline void bitmap_or(
- + IN bitmap4 *restrict dst,
- + IN const bitmap4 *restrict src)
- +{
- + uint32_t i, count = 0;
- + for (i = 0; i < 3; i++) {
- + dst->arr[i] = ((i < dst->count)?dst->arr[i]:0) | ((i < src->count)?src->arr[i]:0);
- + if (dst->arr[i])
- + count = i+1;
- + }
- + dst->count = min(dst->count, count);
- +}
- static __inline void bitmap4_cpy(
- OUT bitmap4 *restrict dst,
- --
- 2.45.1
- From 76c56cd8a941a557be684eae871c2a38f611f71e Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 10:37:45 +0200
- Subject: [PATCH 06/11] daemon: |bitmap_*()| functions should use
- |BITMAP4_MAXCOUNT| instead of |3|
- |bitmap_*()| functions should use |BITMAP4_MAXCOUNT| instead of |3|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/daemon/util.h b/daemon/util.h
- index 058da7b..6938372 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -125,7 +125,7 @@ static __inline void bitmap_intersect(
- IN const bitmap4 *restrict src)
- {
- uint32_t i, count = 0;
- - for (i = 0; i < 3; i++) {
- + for (i = 0; i < BITMAP4_MAXCOUNT; i++) {
- dst->arr[i] = ((i < dst->count)?dst->arr[i]:0) & ((i < src->count)?src->arr[i]:0);
- if (dst->arr[i])
- count = i+1;
- @@ -137,7 +137,7 @@ static __inline void bitmap_or(
- IN const bitmap4 *restrict src)
- {
- uint32_t i, count = 0;
- - for (i = 0; i < 3; i++) {
- + for (i = 0; i < BITMAP4_MAXCOUNT; i++) {
- dst->arr[i] = ((i < dst->count)?dst->arr[i]:0) | ((i < src->count)?src->arr[i]:0);
- if (dst->arr[i])
- count = i+1;
- --
- 2.45.1
- From e6a26a6ec277782dadca5b03b02ce800377d43cc Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 18:09:54 +0200
- Subject: [PATCH 07/11] daemon: |nfs41_cached_getattr()| should have an
- argument to ask for extra attributes
- |nfs41_cached_getattr()| should have an argument to ask for extra
- attributes-
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 72 +++++++++++++++++++---------------------------
- daemon/getattr.c | 27 +++++++++++++++--
- daemon/nfs41_ops.c | 42 +++++++++++++--------------
- daemon/nfs41_ops.h | 1 +
- daemon/open.c | 2 +-
- daemon/readdir.c | 6 ++--
- daemon/setattr.c | 2 +-
- 7 files changed, 79 insertions(+), 73 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 370f2d3..3e00c4f 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -326,62 +326,47 @@ static int handle_getacl(void *daemon_context, nfs41_upcall *upcall)
- PSID osid = NULL, gsid = NULL;
- DWORD sid_len;
- char owner[NFS4_FATTR4_OWNER_LIMIT+1], group[NFS4_FATTR4_OWNER_LIMIT+1];
- + bitmap4 owner_group_acl_bitmap = {
- + .count = 2,
- + .arr[0] = 0,
- + .arr[1] = FATTR4_WORD1_OWNER|FATTR4_WORD1_OWNER_GROUP
- + };
- nfsacl41 acl = { 0 };
- DPRINTF(ACLLVL1, ("--> handle_getacl(state->path.path='%s')\n",
- state->path.path));
- if (args->query & DACL_SECURITY_INFORMATION) {
- -use_nfs41_getattr:
- - bitmap4 attr_request = { 0 };
- - (void)memset(&info, 0, sizeof(nfs41_file_info));
- - info.owner = owner;
- - info.owner_group = group;
- -
- - attr_request.count = 2;
- - attr_request.arr[0] = FATTR4_WORD0_ACL;
- - attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- - info.acl = &acl;
- - status = nfs41_getattr(state->session, &state->file, &attr_request, &info);
- - if (status) {
- - eprintf("handle_getacl: nfs41_getattr() failed with %d\n",
- - status);
- - goto out;
- - }
- + owner_group_acl_bitmap.arr[0] |= FATTR4_WORD0_ACL;
- }
- - else {
- - (void)memset(&info, 0, sizeof(nfs41_file_info));
- - info.owner = owner;
- - info.owner_group = group;
- - status = nfs41_cached_getattr(state->session, &state->file, &info);
- - if (status) {
- - eprintf("handle_getacl: nfs41_cached_getattr() failed with %d\n",
- - status);
- - goto out;
- - }
- + (void)memset(&info, 0, sizeof(nfs41_file_info));
- + info.owner = owner;
- + info.owner_group = group;
- + info.acl = &acl;
- - EASSERT(info.attrmask.count > 1);
- -
- - /*
- - * In rare cases owner/owner_group are not in the cache
- - * (usually for new files). In this case do a full
- - * roundtrip to the NFS server to get the data...
- - */
- - if ((bitmap_isset(&info.attrmask, 1,
- - FATTR4_WORD1_OWNER) == false) ||
- - (bitmap_isset(&info.attrmask, 1,
- - FATTR4_WORD1_OWNER_GROUP) == false)) {
- - DPRINTF(ACLLVL2, ("handle_getattr: owner/owner_group not in cache, doing full lookup...\n"));
- - goto use_nfs41_getattr;
- - }
- + /*
- + * |nfs41_cached_getattr()| will first try to get all information from
- + * the cache. But if bits are missing (e.g. |FATTR4_WORD0_ACL|, then
- + * this will do a server roundtrip to get the missing data
- + */
- + status = nfs41_cached_getattr(state->session,
- + &state->file, &owner_group_acl_bitmap, &info);
- + if (status) {
- + eprintf("handle_getacl: nfs41_cached_getattr() failed with %d\n",
- + status);
- + goto out;
- }
- EASSERT(info.attrmask.count > 1);
- - EASSERT(bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER) &&
- - bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER_GROUP));
- if (args->query & DACL_SECURITY_INFORMATION) {
- - EASSERT(bitmap_isset(&info.attrmask, 0, FATTR4_WORD0_ACL));
- + EASSERT(bitmap_isset(&info.attrmask, 0, FATTR4_WORD0_ACL) == true);
- + }
- + if (args->query & OWNER_SECURITY_INFORMATION) {
- + EASSERT(bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER) == true);
- + }
- + if (args->query & GROUP_SECURITY_INFORMATION) {
- + EASSERT(bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER_GROUP) == true);
- }
- status = InitializeSecurityDescriptor(&sec_desc,
- @@ -433,6 +418,7 @@ use_nfs41_getattr:
- goto out;
- }
- }
- +
- if (args->query & DACL_SECURITY_INFORMATION) {
- DPRINTF(ACLLVL2, ("handle_getacl: DACL_SECURITY_INFORMATION\n"));
- status = convert_nfs4acl_2_dacl(nfs41dg,
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index 7c8b2d1..752a31b 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -37,19 +37,40 @@
- int nfs41_cached_getattr(
- IN nfs41_session *session,
- IN nfs41_path_fh *file,
- + IN OPTIONAL bitmap4 *extra_attr_request,
- OUT nfs41_file_info *info)
- {
- int status;
- + bool bits_missing = false;
- /* first look for cached attributes */
- status = nfs41_attr_cache_lookup(session_name_cache(session),
- file->fh.fileid, info);
- - if (status) {
- + if ((status == 0) && extra_attr_request) {
- + uint32_t i;
- +
- + /* Check if bits are missing... */
- + for (i=0 ; i < extra_attr_request->count ; i++) {
- + if ((extra_attr_request->arr[i] != 0) &&
- + ((((i < info->attrmask.count)?(info->attrmask.arr[i]):0) &
- + extra_attr_request->arr[i]) == 0)) {
- + bits_missing = true;
- + DPRINTF(1, ("nfs41_cached_getattr: bits missing %d\n", i));
- + break;
- + }
- + }
- + }
- +
- + if (status || bits_missing) {
- /* fetch attributes from the server */
- bitmap4 attr_request;
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- + if (extra_attr_request) {
- + bitmap_or(&attr_request, extra_attr_request);
- + }
- +
- status = nfs41_getattr(session, file, &attr_request, info);
- if (status) {
- eprintf("nfs41_cached_getattr: "
- @@ -88,7 +109,7 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- nfs41_open_state *state = upcall->state_ref;
- nfs41_file_info info = { 0 };
- - status = nfs41_cached_getattr(state->session, &state->file, &info);
- + status = nfs41_cached_getattr(state->session, &state->file, NULL, &info);
- if (status) {
- eprintf("handle_getattr(state->path.path='%s'): "
- "nfs41_cached_getattr() failed with %d\n",
- @@ -98,7 +119,7 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- }
- if (info.type == NF4LNK) {
- - nfs41_file_info target_info;
- + nfs41_file_info target_info = { 0 };
- int target_status = nfs41_symlink_follow(upcall->root_ref,
- state->session, &state->file, &target_info);
- if (target_status == NO_ERROR) {
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 862ce0e..0f890e7 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -1478,28 +1478,26 @@ int nfs41_setattr(
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- - if (info->attrmask.count >= 2) {
- - /*
- - * If we set owner and/or owner_group make sure we ask
- - * the server to send the values back for two reasons:
- - * 1, Handle cases like "all_squash" (e.g. nfsd turns
- - * owner/owner_group always into "nobody"/"nogroup")
- - * 2. Make sure we update the name cache with the new
- - * owner/owner_group
- - *
- - * Note that this can be a bit tricky as we might pass
- - * a "name@domain" string to the server, but get a numeric
- - * uid/gid as strings back, which means the name cache
- - * might have both representations.
- - */
- - if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
- - attr_request.count = 2;
- - attr_request.arr[1] |= FATTR4_WORD1_OWNER;
- - }
- - if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- - attr_request.count = 2;
- - attr_request.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- - }
- + /*
- + * If we set owner and/or owner_group make sure we ask
- + * the server to send the values back for two reasons:
- + * 1, Handle cases like "all_squash" (e.g. nfsd turns
- + * owner/owner_group always into "nobody"/"nogroup")
- + * 2. Make sure we update the name cache with the new
- + * owner/owner_group
- + *
- + * Note that this can be a bit tricky as we might pass
- + * a "name@domain" string to the server, but get a numeric
- + * uid/gid as strings back, which means the name cache
- + * might have both representations.
- + */
- + if (bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_OWNER)) {
- + attr_request.count = __max(attr_request.count, 2);
- + attr_request.arr[1] |= FATTR4_WORD1_OWNER;
- + }
- + if (bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_OWNER_GROUP)) {
- + attr_request.count = __max(attr_request.count, 2);
- + attr_request.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- }
- compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
- diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h
- index f57f8dc..91cb766 100644
- --- a/daemon/nfs41_ops.h
- +++ b/daemon/nfs41_ops.h
- @@ -1331,6 +1331,7 @@ int nfs41_superblock_getattr(
- int nfs41_cached_getattr(
- IN nfs41_session *session,
- IN nfs41_path_fh *file,
- + IN OPTIONAL bitmap4 *extra_attr_request,
- OUT nfs41_file_info *info);
- int nfs41_remove(
- diff --git a/daemon/open.c b/daemon/open.c
- index aeaae11..2ba788a 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -867,7 +867,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- if (args->create_opts & FILE_OPEN_REPARSE_POINT) {
- /* continue and open the symlink itself, but we need to
- * know if the target is a regular file or directory */
- - nfs41_file_info target_info;
- + nfs41_file_info target_info = { 0 };
- int target_status = nfs41_symlink_follow(upcall->root_ref,
- state->session, &state->file, &target_info);
- if (target_status == NO_ERROR) {
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index f3564bf..a754197 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -515,7 +515,7 @@ static int lookup_symlink(
- {
- nfs41_abs_path path;
- nfs41_path_fh file;
- - nfs41_file_info info;
- + nfs41_file_info info = { 0 };
- int status;
- status = format_abs_path(parent->path, name, &path);
- @@ -686,7 +686,7 @@ static int readdir_add_dots(
- ZeroMemory(&entry->attr_info, sizeof(nfs41_file_info));
- status = nfs41_cached_getattr(state->session,
- - &state->file, &entry->attr_info);
- + &state->file, NULL, &entry->attr_info);
- if (status) {
- DPRINTF(0, ("readdir_add_dots: failed to add '.' entry.\n"));
- goto out;
- @@ -719,7 +719,7 @@ static int readdir_add_dots(
- ZeroMemory(&entry->attr_info, sizeof(nfs41_file_info));
- status = nfs41_cached_getattr(state->session,
- - &state->parent, &entry->attr_info);
- + &state->parent, NULL, &entry->attr_info);
- if (status) {
- status = ERROR_FILE_NOT_FOUND;
- DPRINTF(0, ("readdir_add_dots: failed to add '..' entry.\n"));
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index 1e2bfdd..a994548 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -71,7 +71,7 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- (void)memset(&old_info, 0, sizeof(old_info));
- getattr_status = nfs41_cached_getattr(state->session,
- - &state->file, &old_info);
- + &state->file, NULL, &old_info);
- if (getattr_status) {
- DPRINTF(0, ("handle_nfs41_setattr_basicinfo(args->path='%s'): "
- "nfs41_cached_getattr() failed with error %d.\n",
- --
- 2.45.1
- From c04b82bea610e00d19f4a56108b2ca59d8f0aec4 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 18:15:29 +0200
- Subject: [PATCH 08/11] daemon: |UTIL_GETRELTIME()| should use |ULL|, not |UL|
- |UTIL_GETRELTIME()| should use |ULL|, not |UL|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/daemon/util.h b/daemon/util.h
- index 6938372..3f640cc 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -47,7 +47,7 @@ enum stable_how4;
- * so hibernation longer than |NAME_CACHE_EXPIRATION| will
- * automagically invalidate the cache
- */
- -#define UTIL_GETRELTIME() (GetTickCount64()/1000UL)
- +#define UTIL_GETRELTIME() (GetTickCount64()/1000ULL)
- #define UTIL_DIFFRELTIME(t1, t2) \
- (((signed long long)(t1))-((signed long long)(t2)))
- typedef ULONGLONG util_reltimestamp;
- --
- 2.45.1
- From df9681d5919093091ce8400cdabd2fc72100f196 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 18:50:17 +0200
- Subject: [PATCH 09/11] daemon: Use |__max()| to adjust the |bitmap4.count| for
- additional attributes
- Use |__max()| to adjust the |bitmap4.count| for additional attributes.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 7 +++----
- daemon/setattr.c | 18 +++++++++---------
- 2 files changed, 12 insertions(+), 13 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 3e00c4f..0a54edc 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -1391,7 +1391,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- info.owner = ownerbuf;
- info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- EASSERT_MSG(info.owner[0] != '\0',
- ("info.owner='%s'\n", info.owner));
- @@ -1413,7 +1413,7 @@ 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;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- EASSERT_MSG(info.owner_group[0] != '\0',
- ("info.owner_group='%s'\n", info.owner_group));
- @@ -1451,8 +1451,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- info.acl = &nfs4_acl;
- info.attrmask.arr[0] |= FATTR4_WORD0_ACL;
- - if (!info.attrmask.count)
- - info.attrmask.count = 1;
- + info.attrmask.count = __max(info.attrmask.count, 1);
- }
- /* break read delegations before SETATTR */
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index a994548..2a87332 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -87,15 +87,15 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- if (info.hidden != old_info.hidden) {
- info.attrmask.arr[0] |= FATTR4_WORD0_HIDDEN;
- - info.attrmask.count = 1;
- + info.attrmask.count = __max(info.attrmask.count, 1);
- }
- if (info.archive != old_info.archive) {
- info.attrmask.arr[0] |= FATTR4_WORD0_ARCHIVE;
- - info.attrmask.count = 1;
- + info.attrmask.count = __max(info.attrmask.count, 1);
- }
- if (info.system != old_info.system) {
- info.attrmask.arr[1] |= FATTR4_WORD1_SYSTEM;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- EASSERT_MSG(((basic_info->FileAttributes & FILE_ATTRIBUTE_EA) == 0),
- @@ -112,13 +112,13 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- if (basic_info->FileAttributes & FILE_ATTRIBUTE_READONLY) {
- info.mode = 0444;
- info.attrmask.arr[1] |= FATTR4_WORD1_MODE;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- else {
- if (old_info.mode == 0444) {
- info.mode = 0644;
- info.attrmask.arr[1] |= FATTR4_WORD1_MODE;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- }
- @@ -132,28 +132,28 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- file_time_to_nfs_time(&basic_info->CreationTime,
- &info.time_create);
- info.attrmask.arr[1] |= FATTR4_WORD1_TIME_CREATE;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- /* time_access_set */
- if (basic_info->LastAccessTime.QuadPart > 0) {
- file_time_to_nfs_time(&basic_info->LastAccessTime,
- &info.time_access);
- info.attrmask.arr[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- /* time_modify_set */
- if (basic_info->LastWriteTime.QuadPart > 0) {
- file_time_to_nfs_time(&basic_info->LastWriteTime,
- &info.time_modify);
- info.attrmask.arr[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
- - info.attrmask.count = 2;
- + info.attrmask.count = __max(info.attrmask.count, 2);
- }
- }
- /* mask out unsupported attributes */
- nfs41_superblock_supported_attrs(superblock, &info.attrmask);
- - if (!info.attrmask.count)
- + if (info.attrmask.count == 0)
- goto out;
- /* break read delegations before SETATTR */
- --
- 2.45.1
- From 4953fd90c04d469ca09ff7d422a382ce349c5000 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 18:53:22 +0200
- Subject: [PATCH 10/11] daemon: Use |bitmap_isset()| instead of "manual"
- testing
- Use |bitmap_isset()| instead of "manual" testing.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_ops.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 0f890e7..ba412a0 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -1457,7 +1457,7 @@ int nfs41_setattr(
- nfs41_putfh_args putfh_args;
- nfs41_putfh_res putfh_res;
- nfs41_setattr_args setattr_args;
- - nfs41_setattr_res setattr_res;
- + nfs41_setattr_res setattr_res = { 0 };
- nfs41_getattr_args getattr_args;
- nfs41_getattr_res getattr_res NDSH(= { 0 });
- bitmap4 attr_request;
- @@ -1516,11 +1516,10 @@ int nfs41_setattr(
- nfs41_attr_cache_update(session_name_cache(session),
- file->fh.fileid, info);
- - if (((setattr_res.attrsset.count > 0) &&
- - (setattr_res.attrsset.arr[0] & FATTR4_WORD0_SIZE)) ||
- - ((setattr_res.attrsset.count > 1) &&
- - (setattr_res.attrsset.arr[1] & FATTR4_WORD1_SPACE_USED)))
- + if (bitmap_isset(&setattr_res.attrsset, 0, FATTR4_WORD0_SIZE) ||
- + bitmap_isset(&setattr_res.attrsset, 1, FATTR4_WORD1_SPACE_USED)) {
- nfs41_superblock_space_changed(file->fh.superblock);
- + }
- out:
- return status;
- }
- --
- 2.45.1
- From 532b3886824dc483308d353a163d07bd32a2aa67 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 25 Jun 2025 19:06:47 +0200
- Subject: [PATCH 11/11] daemon: Fix use of wrong var from commit
- 'daemon,nfs41_build_features.h: Add build option to treat unresolveable
- symlinks as symdirs'
- Fix use of wrong variable from commit 'daemon,nfs41_build_features.h:
- Add build option to treat unresolveable symlinks as symdirs'
- Reported-by: Aurelien Couderc <aurelien.couderc2002@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/open.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/daemon/open.c b/daemon/open.c
- index 2ba788a..ac7d102 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -875,9 +875,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- }
- else {
- #ifdef NFS41_DRIVER_TREAT_UNRESOLVEABLE_SYMLINKS_AS_DIRS
- - target_info.type = TRUE;
- + info.symlink_dir = TRUE;
- #else
- - target_info.type = FALSE;
- + info.symlink_dir = FALSE;
- #endif /* NFS41_DRIVER_TREAT_UNRESOLVEABLE_SYMLINKS_AS_DIRS */
- }
- } else {
- --
- 2.45.1
msnfs41client: Patches for misc bugfixes, cleanup+misc, 2025-06-25
Posted by Anonymous on Wed 25th Jun 2025 18:41
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.