pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


UNC mount path prototype
Posted by Anonymous on Wed 29th Nov 2023 15:52
raw | new post
view followups (newest first): UNC mount path prototype by Anonymous

  1. diff --git a/daemon/getattr.c b/daemon/getattr.c
  2. index 7c5f241..7621dba 100644
  3. --- a/daemon/getattr.c
  4. +++ b/daemon/getattr.c
  5. @@ -59,8 +59,19 @@ int nfs41_cached_getattr(
  6.  static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
  7.  {
  8.      int status;
  9. +#if 1
  10. +    EASSERT(length > 4);
  11. +    if (length <= 4) {
  12. +        status = ERROR_INVALID_PARAMETER;
  13. +        goto out;
  14. +    }
  15. +    EASSERT(upcall->state_ref != NULL);
  16. +    if (upcall->state_ref == NULL) {
  17. +        status = ERROR_INVALID_PARAMETER;
  18. +        goto out;
  19. +    }
  20. +#endif
  21.      getattr_upcall_args *args = &upcall->args.getattr;
  22. -
  23.      status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
  24.      if (status) goto out;
  25.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  26. @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  27.      nfs41_open_state *state = upcall->state_ref;
  28.      nfs41_file_info info = { 0 };
  29.  
  30. +#if 1
  31. +    if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
  32. +        eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
  33. +        status = ERROR_INVALID_PARAMETER;
  34. +        goto out;
  35. +    }
  36. +
  37. +    EASSERT(state->file.fh.superblock != NULL);
  38. +    if (state->file.fh.superblock == NULL) {
  39. +        /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
  40. +        status = ERROR_INVALID_PARAMETER;
  41. +        goto out;
  42. +    }
  43. +#endif
  44. +
  45.      status = nfs41_cached_getattr(state->session, &state->file, &info);
  46.      if (status) {
  47.          eprintf("nfs41_cached_getattr() failed with %d\n", status);
  48. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  49. index bcca070..f2a4f22 100644
  50. --- a/daemon/nfs41_ops.c
  51. +++ b/daemon/nfs41_ops.c
  52. @@ -400,6 +400,9 @@ int nfs41_open(
  53.      bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ
  54.          || delegation->type == OPEN_DELEGATE_WRITE;
  55.  
  56. +    EASSERT(parent);
  57. +    EASSERT(parent->fh.superblock);
  58. +
  59.      /* depending on the claim type, OPEN expects CURRENT_FH set
  60.       * to either the parent directory, or to the file itself */
  61.      switch (claim->claim) {
  62. diff --git a/daemon/open.c b/daemon/open.c
  63. index 4b2a335..487c341 100644
  64. --- a/daemon/open.c
  65. +++ b/daemon/open.c
  66. @@ -99,6 +99,24 @@ static void open_state_free(
  67.  void nfs41_open_state_ref(
  68.      IN nfs41_open_state *state)
  69.  {
  70. +#if 1
  71. +    /*
  72. +     * gisburn: fixme: sometimes this happens under high parallel
  73. +     * usage with multiple mounts - but why ?
  74. +     * 0:038> kp
  75. +     * Child-SP          RetAddr           Call Site
  76. +     * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
  77. +     * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
  78. +     * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
  79. +     * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
  80. +     * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
  81. +     * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
  82. +     */
  83. +    EASSERT(state != NULL);
  84. +    if (state == NULL)
  85. +        return;
  86. +#endif
  87. +
  88.      const LONG count = InterlockedIncrement(&state->ref_count);
  89.  
  90.      dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
  91. diff --git a/daemon/upcall.c b/daemon/upcall.c
  92. index bd13c61..7778429 100644
  93. --- a/daemon/upcall.c
  94. +++ b/daemon/upcall.c
  95. @@ -121,6 +121,7 @@ int upcall_parse(
  96.      /* parse the operation's arguments */
  97.      op = g_upcall_op_table[upcall->opcode];
  98.      if (op && op->parse) {
  99. +        EASSERT(length > 0);
  100.          status = op->parse(buffer, length, upcall);
  101.          if (status) {
  102.              eprintf("parsing of upcall '%s' failed with %d.\n",
  103. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  104. index 8b259bb..6d3429f 100644
  105. --- a/dll/nfs41_np.c
  106. +++ b/dll/nfs41_np.c
  107. @@ -28,6 +28,8 @@
  108.  #include "nfs41_np.h"
  109.  #include "options.h"
  110.  
  111. +#define DBG 1
  112. +
  113.  #ifdef DBG
  114.  #define DbgP(_x_) NFS41DbgPrint _x_
  115.  #else
  116. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  117. index 93ee7a9..d43334a 100644
  118. --- a/sys/nfs41_build_features.h
  119. +++ b/sys/nfs41_build_features.h
  120. @@ -32,19 +32,19 @@
  121.  /*
  122.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  123.   */
  124. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  125. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  126.  
  127.  /*
  128.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  129.   * files which do not map to a local account a SID in the
  130.   * Unix_User+x/Unix_Group+x range
  131.   */
  132. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  133. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  134.  
  135.  /*
  136.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  137.   * as "name service"
  138.   */
  139. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  140. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  141.  
  142.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  143. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  144. index 526b064..e005972 100644
  145. --- a/sys/nfs41_driver.c
  146. +++ b/sys/nfs41_driver.c
  147. @@ -54,7 +54,7 @@
  148.  //#define DEBUG_LOCK
  149.  //#define DEBUG_MISC
  150.  #define DEBUG_TIME_BASED_COHERENCY
  151. -//#define DEBUG_MOUNT
  152. +#define DEBUG_MOUNT
  153.  //#define DEBUG_VOLUME_QUERY
  154.  
  155.  //#define ENABLE_TIMINGS
  156. @@ -267,6 +267,8 @@ typedef struct _nfs41_mount_entry {
  157.      HANDLE gss_session;
  158.      HANDLE gssi_session;
  159.      HANDLE gssp_session;
  160. +    UNICODE_STRING SrvName; /* hostname, or hostname@port */
  161. +    WCHAR mntpt_buffer[MAX_PATH];
  162.  } nfs41_mount_entry;
  163.  
  164.  typedef struct _nfs41_mount_list {
  165. @@ -2739,6 +2741,10 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  166.      IN ULONG EaLength,
  167.      IN OUT PNFS41_MOUNT_CONFIG Config)
  168.  {
  169. +    DbgP("----> nfs41_MountConfig_ParseOptions(EaBuffer=%p,EaLength=%ld)\n",
  170. +        (void *)EaBuffer,
  171. +        (long)EaLength);
  172. +    DbgP("max_address=%p\n", (void *)(((char *)EaBuffer)+EaLength));
  173.      NTSTATUS  status = STATUS_SUCCESS;
  174.      PFILE_FULL_EA_INFORMATION Option;
  175.      LPWSTR Name;
  176. @@ -2746,13 +2752,20 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  177.      UNICODE_STRING  usValue;
  178.      Option = EaBuffer;
  179.      while (status == STATUS_SUCCESS) {
  180. +        DbgP("Option=%p\n", (void *)Option);
  181.          Name = (LPWSTR)Option->EaName;
  182.          NameLen = Option->EaNameLength/sizeof(WCHAR);
  183.          
  184. +        DbgP("nfs41_MountConfig_ParseOptions: Name='%*S'/NameLen=%d\n",
  185. +            (int)NameLen, Name, (int)NameLen);
  186. +
  187.          usValue.Length = usValue.MaximumLength = Option->EaValueLength;
  188.          usValue.Buffer = (PWCH)(Option->EaName +
  189.              Option->EaNameLength + sizeof(WCHAR));
  190.  
  191. +        DbgP("nfs41_MountConfig_ParseOptions: option/usValue='%wZ'/%ld\n",
  192. +            &usValue, (long)usValue.Length);
  193. +
  194.          if (wcsncmp(L"ro", Name, NameLen) == 0) {
  195.              status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
  196.                  FALSE, &Config->ReadOnly);
  197. @@ -2834,6 +2847,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  198.              ((PBYTE)Option + Option->NextEntryOffset);
  199.      }
  200.  
  201. +    DbgP("<---- nfs41_MountConfig_ParseOptions, status=%ld\n", (long)status);
  202.      return status;
  203.  }
  204.  
  205. @@ -2996,6 +3010,9 @@ NTSTATUS nfs41_CreateVNetRoot(
  206.  
  207.      if (pCreateNetRootContext->RxContext->Create.EaLength) {
  208.          /* Codepath for nfs_mount.exe */
  209. +        DbgP("Codepath for nfs_mount.exe, %p/%ld\n",
  210. +            pCreateNetRootContext->RxContext->Create.EaBuffer,
  211. +            (long)pCreateNetRootContext->RxContext->Create.EaLength);
  212.  
  213.          /* parse the extended attributes for mount options */
  214.          status = nfs41_MountConfig_ParseOptions(
  215. @@ -3009,6 +3026,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  216.          pVNetRootContext->nocache = Config->nocache;        
  217.      } else {
  218.          /* Codepath for \\server:port\nfs4\path */
  219. +        DbgP("Codepath for \\\\server:port\\nfs4\\path\n");
  220.  
  221.          /* use the SRV_CALL name (without leading \) as the hostname */
  222.          Config->SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1;
  223. @@ -3016,16 +3034,70 @@ NTSTATUS nfs41_CreateVNetRoot(
  224.              pSrvCall->pSrvCallName->Length - sizeof(WCHAR);
  225.          Config->SrvName.MaximumLength =
  226.              pSrvCall->pSrvCallName->MaximumLength - sizeof(WCHAR);
  227. +#define MNTXXX 1
  228. +#ifdef MNTXXX
  229. +        status = nfs41_GetLUID(&luid);
  230. +        if (status)
  231. +            goto out_free;
  232. +
  233. +        PLIST_ENTRY pEntry;
  234. +
  235. +        ExAcquireFastMutex(&pNetRootContext->mountLock);
  236. +        pEntry = &pNetRootContext->mounts.head;
  237. +        pEntry = pEntry->Flink;
  238. +        while (pEntry != NULL) {
  239. +            existing_mount = (nfs41_mount_entry *)CONTAINING_RECORD(pEntry,
  240. +                    nfs41_mount_entry, next);
  241. +
  242. +            if (RtlEqualLuid(&luid, &existing_mount->login_id)) {
  243. +                DbgP("MNTXXX: Found a matching LUID entry\n");
  244. +
  245. +                /* found existing mount */
  246. +                RtlCopyMemory(Config->mntpt_buffer, existing_mount->mntpt_buffer, sizeof(Config->mntpt_buffer));
  247. +                Config->MntPt.Buffer = Config->mntpt_buffer;
  248. +                Config->MntPt.MaximumLength = MAX_PATH;
  249. +                Config->MntPt.Length = wcslen(Config->mntpt_buffer)*2;
  250. +                DbgP("MNTXXX: Found entry Config->MntPt.Buffer='%S', bytelen=%ld\n",
  251. +                    Config->MntPt.Buffer,
  252. +                    (long)Config->MntPt.Length);
  253. +                status = STATUS_SUCCESS;
  254. +                break;
  255. +            }
  256. +            if (pEntry->Flink == &pNetRootContext->mounts.head)
  257. +                break;
  258. +            pEntry = pEntry->Flink;
  259. +        }
  260. +        ExReleaseFastMutex(&pNetRootContext->mountLock);
  261. +
  262. +        DbgP("MNTXXX: mark #1\n");
  263. +
  264. +        if (status != STATUS_SUCCESS)
  265. +            goto out_free;
  266. +        pVNetRootContext->read_only = Config->ReadOnly;
  267. +        pVNetRootContext->write_thru = Config->write_thru;
  268. +        pVNetRootContext->nocache = Config->nocache;
  269. +
  270. +        DbgP("MNTXXX: mark #2\n");
  271. +        DbgP("Codepath for \\\\server:port\\nfs4\\path: Config->MntPt='%wZ'\n",
  272. +            &Config->MntPt);
  273. +
  274. +        DbgP("Codepath for \\\\server:port\\nfs4\\path: Config->SrvName='%wZ'\n",
  275. +            &Config->SrvName);
  276. +        DbgP("MNTXXX: mark #3\n");
  277. +#endif /* MNTXXX */
  278.      }
  279.      pVNetRootContext->MountPathLen = Config->MntPt.Length;
  280.      pVNetRootContext->timeout = Config->timeout;
  281.  
  282.      status = map_sec_flavor(&Config->SecFlavor, &pVNetRootContext->sec_flavor);
  283.      if (status != STATUS_SUCCESS) {
  284. +        DbgP("map_sec_flavor() failed\n");
  285.          DbgP("Invalid rpcsec security flavor %wZ\n", &Config->SecFlavor);
  286.          goto out_free;
  287.      }
  288.  
  289. +DbgP("MNTXXX: mark #4\n");
  290. +
  291.      status = nfs41_GetLUID(&luid);
  292.      if (status)
  293.          goto out_free;
  294. @@ -3090,10 +3162,12 @@ NTSTATUS nfs41_CreateVNetRoot(
  295.  #endif
  296.      }
  297.  
  298. +DbgP("MNTXXX: mark #5\n");
  299.      /* send the mount upcall */
  300.      status = nfs41_mount(Config, pVNetRootContext->sec_flavor,
  301.          &pVNetRootContext->session, &nfs41d_version,
  302.          &pVNetRootContext->FsAttrs);
  303. +DbgP("status(=%ld) = nfs41_mount()\n", (long)status);
  304.      if (status != STATUS_SUCCESS) {
  305.          BOOLEAN MountsEmpty;
  306.          nfs41_IsListEmpty(pNetRootContext->mountLock,
  307. @@ -3127,6 +3201,9 @@ NTSTATUS nfs41_CreateVNetRoot(
  308.              entry->gssp_session = pVNetRootContext->session; break;
  309.          }
  310.          RtlCopyLuid(&entry->login_id, &luid);
  311. +        RtlCopyMemory(entry->mntpt_buffer, Config->mntpt_buffer, sizeof(entry->mntpt_buffer));
  312. +        entry->mntpt_buffer[Config->MntPt.Length] = L'\0';
  313. +        DbgP("NEW MOUNT '%S'\n", entry->mntpt_buffer);
  314.          nfs41_AddEntry(pNetRootContext->mountLock,
  315.              pNetRootContext->mounts, entry);
  316.      } else if (!found_matching_flavor) {
  317. diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh
  318. old mode 100644
  319. new mode 100755

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