pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


Prototype fix for token ref crashes
Posted by Anonymous on Tue 7th May 2024 15:02
raw | new post

  1. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  2. index 9c0d2ee..4f6bf28 100644
  3. --- a/sys/nfs41_driver.c
  4. +++ b/sys/nfs41_driver.c
  5. @@ -1424,6 +1424,7 @@ NTSTATUS handle_upcall(
  6.       * ---- snip ----
  7.       */
  8.      __try {
  9. +        ObReferenceObject(entry->psec_ctx->ClientToken);
  10.          status = SeImpersonateClientEx(entry->psec_ctx, NULL);
  11.      } __except(EXCEPTION_EXECUTE_HANDLER) {
  12.          NTSTATUS code;
  13. @@ -1553,7 +1554,10 @@ NTSTATUS nfs41_UpcallCreate(
  14.          entry->psec_ctx = &entry->sec_ctx;
  15.          status = SeCreateClientSecurityFromSubjectContext(&sec_ctx, &sec_qos,
  16.                      1, entry->psec_ctx);
  17. -        if (status != STATUS_SUCCESS) {
  18. +        if (status == STATUS_SUCCESS) {
  19. +            ObReferenceObject(entry->psec_ctx->ClientToken);
  20. +        }
  21. +        else {
  22.              print_error("nfs41_UpcallCreate: "
  23.                  "SeCreateClientSecurityFromSubjectContext failed with %x\n",
  24.                  status);
  25. @@ -1562,8 +1566,12 @@ NTSTATUS nfs41_UpcallCreate(
  26.          }
  27.  
  28.          SeReleaseSubjectContext(&sec_ctx);
  29. -    } else
  30. +    } else {
  31.          entry->psec_ctx = clnt_sec_ctx;
  32. +        ObReferenceObject(entry->psec_ctx->ClientToken);
  33. +    }
  34. +
  35. +
  36.  
  37.      *entry_out = entry;
  38.  out:
  39. @@ -1995,11 +2003,14 @@ NTSTATUS nfs41_downcall(
  40.      }
  41.      ExReleaseFastMutex(&downcallLock);
  42.      SeStopImpersonatingClient();
  43. +
  44.      if (!found) {
  45.          print_error("Didn't find xid=%lld entry\n", tmp->xid);
  46.          goto out_free;
  47.      }
  48.  
  49. +    ObDereferenceObject(cur->psec_ctx->ClientToken);
  50. +
  51.      ExAcquireFastMutex(&cur->lock);    
  52.      if (cur->state == NFS41_NOT_WAITING) {
  53.          DbgP("[downcall] Nobody is waiting for this request!!!\n");
  54. @@ -2108,6 +2119,7 @@ NTSTATUS nfs41_shutdown_daemon(
  55.      if (status) goto out;
  56.  
  57.      status = nfs41_UpcallWaitForReply(entry, UPCALL_TIMEOUT_DEFAULT);
  58. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  59.      if (entry->psec_ctx == &entry->sec_ctx) {
  60.          SeDeleteClientSecurity(entry->psec_ctx);
  61.      }
  62. @@ -2374,6 +2386,7 @@ NTSTATUS nfs41_unmount(
  63.  
  64.      nfs41_UpcallWaitForReply(entry, timeout);
  65.  
  66. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  67.      if (entry->psec_ctx == &entry->sec_ctx) {
  68.          SeDeleteClientSecurity(entry->psec_ctx);
  69.      }
  70. @@ -2757,6 +2770,7 @@ NTSTATUS nfs41_mount(
  71.      entry->u.Mount.FsAttrs = FsAttrs;
  72.  
  73.      status = nfs41_UpcallWaitForReply(entry, config->timeout);
  74. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  75.      if (entry->psec_ctx == &entry->sec_ctx) {
  76.          SeDeleteClientSecurity(entry->psec_ctx);
  77.      }
  78. @@ -3949,6 +3963,7 @@ retry_on_link:
  79.  
  80.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  81.  #ifndef USE_MOUNT_SEC_CONTEXT
  82. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  83.      if (entry->psec_ctx == &entry->sec_ctx) {
  84.          SeDeleteClientSecurity(entry->psec_ctx);
  85.      }
  86. @@ -4352,6 +4367,9 @@ NTSTATUS nfs41_CloseSrvOpen(
  87.          entry->u.Close.renamed = nfs41_fcb->Renamed;
  88.  
  89.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  90. +
  91. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  92. +
  93.  #ifndef USE_MOUNT_SEC_CONTEXT
  94.      SeDeleteClientSecurity(&nfs41_fobx->sec_ctx);
  95.  #endif
  96. @@ -4523,6 +4541,9 @@ NTSTATUS nfs41_QueryDirectory(
  97.      entry->u.QueryFile.return_single = RxContext->QueryDirectory.ReturnSingleEntry;
  98.  
  99.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  100. +
  101. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  102. +
  103.      if (status) goto out;
  104.      MmUnlockPages(entry->u.QueryFile.mdl);
  105.  
  106. @@ -4724,6 +4745,9 @@ NTSTATUS nfs41_QueryVolumeInformation(
  107.      entry->buf_len = RxContext->Info.LengthRemaining;
  108.  
  109.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  110. +
  111. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  112. +
  113.      if (status) goto out;
  114.  
  115.      if (entry->status == STATUS_BUFFER_TOO_SMALL) {
  116. @@ -4971,6 +4995,9 @@ NTSTATUS nfs41_SetEaInformation(
  117.      entry->buf_len = buflen;
  118.      
  119.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  120. +
  121. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  122. +
  123.      if (status) goto out;
  124.  #ifdef ENABLE_TIMINGS
  125.      if (entry->status == STATUS_SUCCESS) {
  126. @@ -5075,6 +5102,9 @@ static NTSTATUS QueryCygwinSymlink(
  127.      entry->u.Symlink.set = FALSE;
  128.  
  129.      status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
  130. +
  131. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  132. +
  133.      if (status) goto out;
  134.  
  135.      status = map_setea_error(entry->status);
  136. @@ -5231,6 +5261,9 @@ NTSTATUS nfs41_QueryEaInformation(
  137.      entry->u.QueryEa.ReturnSingleEntry = RxContext->QueryEa.ReturnSingleEntry;
  138.  
  139.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  140. +
  141. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  142. +
  143.      if (status) goto out;
  144.  
  145.      if (entry->status == STATUS_SUCCESS) {
  146. @@ -5374,6 +5407,9 @@ NTSTATUS nfs41_QuerySecurityInformation(
  147.      entry->buf_len = RxContext->CurrentIrpSp->Parameters.QuerySecurity.Length;
  148.  
  149.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  150. +
  151. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  152. +
  153.      if (status) goto out;
  154.  
  155.      if (entry->status == STATUS_BUFFER_TOO_SMALL) {
  156. @@ -5512,6 +5548,9 @@ NTSTATUS nfs41_SetSecurityInformation(
  157.  #endif
  158.  
  159.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  160. +
  161. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  162. +
  163.      if (status) goto out;
  164.  
  165.      status = map_query_acl_error(entry->status);
  166. @@ -5626,6 +5665,9 @@ NTSTATUS nfs41_QueryFileInformation(
  167.      entry->buf_len = RxContext->Info.LengthRemaining;
  168.  
  169.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  170. +
  171. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  172. +
  173.      if (status) {
  174.          print_error("nfs41_UpcallWaitForReply() failed, status=%d\n", status);
  175.          goto out;
  176. @@ -5939,6 +5981,9 @@ NTSTATUS nfs41_SetFileInformation(
  177.  #endif
  178.  
  179.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  180. +
  181. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  182. +
  183.      if (status) goto out;
  184.  
  185.      status = map_setfile_error(entry->status);
  186. @@ -6186,6 +6231,9 @@ NTSTATUS nfs41_Read(
  187.       */
  188.      io_delay = pVNetRootContext->timeout + 2 * entry->buf_len / 104857600;
  189.      status = nfs41_UpcallWaitForReply(entry, io_delay);
  190. +
  191. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  192. +
  193.      if (status) goto out;
  194.  
  195.      if (async) {
  196. @@ -6305,6 +6353,9 @@ NTSTATUS nfs41_Write(
  197.       */
  198.      io_delay = pVNetRootContext->timeout + 2 * entry->buf_len / 104857600;
  199.      status = nfs41_UpcallWaitForReply(entry, io_delay);
  200. +
  201. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  202. +
  203.      if (status) goto out;
  204.  
  205.      if (async) {
  206. @@ -6485,6 +6536,9 @@ NTSTATUS nfs41_Lock(
  207.  
  208.  retry_upcall:
  209.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  210. +
  211. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  212. +
  213.      if (status) goto out;
  214.  
  215.      /* blocking locks keep trying until it succeeds */
  216. @@ -6592,6 +6646,9 @@ NTSTATUS nfs41_Unlock(
  217.      }
  218.  
  219.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  220. +
  221. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  222. +
  223.      if (status) goto out;
  224.  
  225.      status = map_lock_errors(entry->status);
  226. @@ -6764,6 +6821,9 @@ NTSTATUS nfs41_SetReparsePoint(
  227.      entry->u.Symlink.set = TRUE;
  228.  
  229.      status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
  230. +
  231. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  232. +
  233.      if (status) goto out;
  234.  
  235.      status = map_symlink_errors(entry->status);
  236. @@ -6850,6 +6910,9 @@ NTSTATUS nfs41_GetReparsePoint(
  237.      entry->u.Symlink.set = FALSE;
  238.  
  239.      status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
  240. +
  241. +    ObDereferenceObject(entry->psec_ctx->ClientToken);
  242. +
  243.      if (status) goto out;
  244.  
  245.      status = map_symlink_errors(entry->status);
  246. @@ -7160,6 +7223,9 @@ VOID fcbopen_main(PVOID ctx)
  247.              entry->buf_len = sizeof(binfo);
  248.  
  249.              status = nfs41_UpcallWaitForReply(entry, UPCALL_TIMEOUT_DEFAULT);
  250. +
  251. +            ObDereferenceObject(entry->psec_ctx->ClientToken);
  252. +
  253.              if (status) goto out;
  254.  
  255.              if (cur->ChangeTime != entry->ChangeTime) {

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