pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


Test patches for getattr
Posted by Anonymous on Sat 4th Nov 2023 14:01
raw | new post

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index 1d1eac4..4297722 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -223,6 +223,18 @@ static int map_name_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_l
  6.              name = "roland_mainz";
  7.              dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
  8.          }
  9. +        else if (!strcmp(name, "swulsch")) {
  10. +            name = "siegfried_wulsch";
  11. +            dprintf(ACLLVL, "map_name_2_sid: remap swulsch --> siegfried_wulsch\n");
  12. +        }
  13. +        else if (!strcmp(name, "197609")) {
  14. +            name = "siegfried_wulsch";
  15. +            dprintf(ACLLVL, "map_name_2_sid: remap 197609 --> siegfried_wulsch\n");
  16. +        }
  17. +        else if (!strcmp(name, "1818")) {
  18. +            name = "siegfried_wulsch";
  19. +            dprintf(ACLLVL, "map_name_2_sid: remap 1818 --> siegfried_wulsch\n");
  20. +        }
  21.      }
  22.  #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  23.  
  24. diff --git a/daemon/getattr.c b/daemon/getattr.c
  25. index 7c5f241..e56f8ca 100644
  26. --- a/daemon/getattr.c
  27. +++ b/daemon/getattr.c
  28. @@ -59,8 +59,19 @@ int nfs41_cached_getattr(
  29.  static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
  30.  {
  31.      int status;
  32. +#if 1
  33. +    EASSERT(length > 4);
  34. +    if (length <= 4) {
  35. +        status = ERROR_INVALID_PARAMETER;
  36. +        goto out;
  37. +    }
  38. +    EASSERT(upcall->state_ref != NULL);
  39. +    if (upcall->state_ref == NULL) {
  40. +        status = ERROR_INVALID_PARAMETER;
  41. +        goto out;
  42. +    }
  43. +#endif
  44.      getattr_upcall_args *args = &upcall->args.getattr;
  45. -
  46.      status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
  47.      if (status) goto out;
  48.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  49. @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  50.      nfs41_open_state *state = upcall->state_ref;
  51.      nfs41_file_info info = { 0 };
  52.  
  53. +#if 1
  54. +    if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
  55. +        eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
  56. +        status = ERROR_INVALID_PARAMETER;
  57. +        goto out;
  58. +    }
  59. +
  60. +    EASSERT(state->file.fh.superblock != NULL);
  61. +    if (state->file.fh.superblock == NULL) {
  62. +        /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
  63. +        status = ERROR_INVALID_PARAMETER;
  64. +        goto out;
  65. +    }
  66. +#endif
  67. +
  68.      status = nfs41_cached_getattr(state->session, &state->file, &info);
  69.      if (status) {
  70.          eprintf("nfs41_cached_getattr() failed with %d\n", status);
  71. diff --git a/daemon/idmap.c b/daemon/idmap.c
  72. index 00af1fe..6947b6c 100644
  73. --- a/daemon/idmap.c
  74. +++ b/daemon/idmap.c
  75. @@ -133,7 +133,7 @@ static const struct config_option g_options[] = {
  76.      OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID),
  77.  
  78.      /* caching configuration */
  79. -    OPT_INT("cache_ttl", "60", cache_ttl),
  80. +    OPT_INT("cache_ttl", "6000", cache_ttl),
  81.  };
  82.  
  83.  
  84. diff --git a/daemon/open.c b/daemon/open.c
  85. index 3071041..23e9017 100644
  86. --- a/daemon/open.c
  87. +++ b/daemon/open.c
  88. @@ -99,6 +99,24 @@ static void open_state_free(
  89.  void nfs41_open_state_ref(
  90.      IN nfs41_open_state *state)
  91.  {
  92. +#if 1
  93. +    /*
  94. +     * gisburn: fixme: sometimes this happens under high parallel
  95. +     * usage with multiple mounts - but why ?
  96. +     * 0:038> kp
  97. +     * Child-SP          RetAddr           Call Site
  98. +     * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
  99. +     * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
  100. +     * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
  101. +     * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
  102. +     * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
  103. +     * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
  104. +     */
  105. +    EASSERT(state != NULL);
  106. +    if (state == NULL)
  107. +        return;
  108. +#endif
  109. +
  110.      const LONG count = InterlockedIncrement(&state->ref_count);
  111.  
  112.      dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
  113. diff --git a/daemon/upcall.c b/daemon/upcall.c
  114. index bd13c61..6303147 100644
  115. --- a/daemon/upcall.c
  116. +++ b/daemon/upcall.c
  117. @@ -121,6 +121,7 @@ int upcall_parse(
  118.      /* parse the operation's arguments */
  119.      op = g_upcall_op_table[upcall->opcode];
  120.      if (op && op->parse) {
  121. +       EASSERT(length > 0);
  122.          status = op->parse(buffer, length, upcall);
  123.          if (status) {
  124.              eprintf("parsing of upcall '%s' failed with %d.\n",
  125. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  126. index 93ee7a9..d43334a 100644
  127. --- a/sys/nfs41_build_features.h
  128. +++ b/sys/nfs41_build_features.h
  129. @@ -32,19 +32,19 @@
  130.  /*
  131.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  132.   */
  133. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  134. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  135.  
  136.  /*
  137.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  138.   * files which do not map to a local account a SID in the
  139.   * Unix_User+x/Unix_Group+x range
  140.   */
  141. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  142. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  143.  
  144.  /*
  145.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  146.   * as "name service"
  147.   */
  148. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  149. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  150.  
  151.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  152. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  153. index 0368732..ff0a54f 100644
  154. --- a/sys/nfs41_driver.c
  155. +++ b/sys/nfs41_driver.c
  156. @@ -1008,7 +1008,11 @@ NTSTATUS marshal_nfs41_filequery(
  157.      if (status) goto out;
  158.      else tmp += *len;
  159.  
  160. -    header_len = *len + 2 * sizeof(ULONG);
  161. +    header_len = *len + 2 * sizeof(ULONG)
  162. +#if 1
  163. ++ 2*sizeof(HANDLE)
  164. +#endif
  165. +    ;
  166.      if (header_len > buf_len) {
  167.          status = STATUS_INSUFFICIENT_RESOURCES;
  168.          goto out;
  169. @@ -1484,6 +1488,7 @@ NTSTATUS nfs41_UpcallWaitForReply(
  170.          /* 02/15/2011 cbodley: added NFS41_UNLOCK for the same reason. locking
  171.           * tests were triggering an interrupted unlock, which led to a bugcheck
  172.           * in CloseSrvOpen() */
  173. +retry_wait:
  174.  #define MAKE_WAITONCLOSE_NONITERRUPTABLE
  175.  #ifdef MAKE_WAITONCLOSE_NONITERRUPTABLE
  176.          if (entry->opcode == NFS41_CLOSE || entry->opcode == NFS41_UNLOCK)
  177. @@ -1509,9 +1514,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
  178.          goto out;
  179.  
  180.      switch(status) {
  181. -    case STATUS_SUCCESS: break;
  182.      case STATUS_USER_APC:
  183.      case STATUS_ALERTED:
  184. +        DbgP("retry waiting for '%s' entry=%p xid=%lld\n",
  185. +            opcode2string(entry->opcode), entry, entry->xid);
  186. +        goto retry_wait;
  187. +    case STATUS_SUCCESS: break;
  188.      default:
  189.          ExAcquireFastMutex(&entry->lock);
  190.          if (entry->state == NFS41_DONE_PROCESSING) {
  191. @@ -2502,7 +2510,11 @@ NTSTATUS _nfs41_CreateSrvCall(
  192.      }
  193.  
  194.      /* Let's create our own representation of the server */
  195. -    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(PagedPool,
  196. +#if 1
  197. +    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(PagedPool,
  198. +#else
  199. +    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(NonPagedPool,
  200. +#endif
  201.          sizeof(NFS41_SERVER_ENTRY), NFS41_MM_POOLTAG);
  202.      if (pServerEntry == NULL) {
  203.          status = STATUS_INSUFFICIENT_RESOURCES;
  204. @@ -5278,9 +5290,24 @@ NTSTATUS nfs41_QueryFileInformation(
  205.      DbgEn();
  206.      print_debug_filedirquery_header(RxContext);
  207.  #endif
  208. +    DbgP("--> nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld, "
  209. +        "RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength=%ld\n",
  210. +        (long)RxContext->Info.LengthRemaining,
  211. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength);
  212.  
  213.      status = check_nfs41_dirquery_args(RxContext);
  214. -    if (status) goto out;
  215. +    if (status) {
  216. +       print_error("check_nfs41_dirquery_args failed.\n");
  217. +        goto out;
  218. +    }
  219. +
  220. +    RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
  221. +
  222. +    DbgP("nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld, "
  223. +        "RxContext->LowIoContext.ParamsFor.IoCtl.{InputBufferLength=%ld,OutputBufferLength=%ld}\n",
  224. +        (long)RxContext->Info.LengthRemaining,
  225. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.InputBufferLength,
  226. +        (long)RxContext->LowIoContext.ParamsFor.IoCtl.OutputBufferLength);
  227.  
  228.      switch (InfoClass) {
  229.      case FileEaInformation:
  230. @@ -5307,19 +5334,27 @@ NTSTATUS nfs41_QueryFileInformation(
  231.      status = nfs41_UpcallCreate(NFS41_FILE_QUERY, &nfs41_fobx->sec_ctx,
  232.          pVNetRootContext->session, nfs41_fobx->nfs41_open_state,
  233.          pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
  234. -    if (status) goto out;
  235. +    if (status) {
  236. +        print_error("nfs41_UpcallCreate() failed, status=%d\n", status);
  237. +        goto out;
  238. +    }
  239.  
  240.      entry->u.QueryFile.InfoClass = InfoClass;
  241.      entry->buf = RxContext->Info.Buffer;
  242.      entry->buf_len = RxContext->Info.LengthRemaining;
  243.  
  244.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  245. -    if (status) goto out;
  246. -
  247. +    if (status) {
  248. +        print_error("nfs41_UpcallWaitForReply() failed, status=%d\n", status);
  249. +        goto out;
  250. +    }
  251. +    
  252.      if (entry->status == STATUS_BUFFER_TOO_SMALL) {
  253.          RxContext->InformationToReturn = entry->buf_len;
  254. +        print_error("entry->status == STATUS_BUFFER_TOO_SMALL\n");
  255.          status = STATUS_BUFFER_TOO_SMALL;
  256.      } else if (entry->status == STATUS_SUCCESS) {
  257. +        print_error("entry->status == STATUS_SUCCESS\n");
  258.          BOOLEAN DeletePending = FALSE;
  259.  #ifdef ENABLE_TIMINGS
  260.          InterlockedIncrement(&getattr.sops);
  261. @@ -5375,9 +5410,12 @@ NTSTATUS nfs41_QueryFileInformation(
  262.              print_std_info(1, &nfs41_fcb->StandardInfo);
  263.  #endif
  264.              break;
  265. +        default:
  266. +            print_error("Unhandled/unsupported InfoClass(%d)\n", (int)InfoClass);
  267.          }
  268.      } else {
  269.          status = map_queryfile_error(entry->status);
  270. +        print_error("status(0x%lx) = map_queryfile_error(entry->status(0x%lx));\n", (long)status, (long)entry->status);
  271.      }
  272.      RxFreePool(entry);
  273.  out:
  274. @@ -5393,6 +5431,7 @@ out:
  275.  #ifdef DEBUG_FILE_QUERY
  276.      DbgEx();
  277.  #endif
  278. +    DbgP("<-- nfs41_QueryFileInformation, status=0x%lx\n", (long)status);
  279.      return status;
  280.  }

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at