pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


non-working fix for crash in |fcbopen_main()|
Posted by Anonymous on Fri 10th May 2024 10:33
raw | new post

  1. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  2. index 94c3070..53848bc 100644
  3. --- a/sys/nfs41_driver.c
  4. +++ b/sys/nfs41_driver.c
  5. @@ -41,17 +41,6 @@
  6.  #include "nfs41_build_features.h"
  7.  
  8.  
  9. -/*
  10. - * FIXME: NFS41_DRIVER_SETGID_NEWGRP_SUPPORT - we need the correct
  11. - * |TOKEN_PRIMARY_GROUP| for |setgid()|/newgrp(1)
  12. - * support, and |#define USE_MOUNT_SEC_CONTEXT| currently breaks
  13. - * that
  14. - */
  15. -#ifndef NFS41_DRIVER_SETGID_NEWGRP_SUPPORT
  16. -#define USE_MOUNT_SEC_CONTEXT 1
  17. -#define STORE_MOUNT_SEC_CONTEXT 1
  18. -#endif
  19. -
  20.  /* debugging printout defines */
  21.  #define DEBUG_MARSHAL_HEADER
  22.  #define DEBUG_MARSHAL_DETAIL
  23. @@ -402,10 +391,6 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION {
  24.      BOOLEAN                 read_only;
  25.      BOOLEAN                 write_thru;
  26.      BOOLEAN                 nocache;
  27. -
  28. -#ifdef STORE_MOUNT_SEC_CONTEXT
  29. -    SECURITY_CLIENT_CONTEXT mount_sec_ctx;
  30. -#endif
  31.  } NFS41_V_NET_ROOT_EXTENSION, *PNFS41_V_NET_ROOT_EXTENSION;
  32.  #define NFS41GetVNetRootExtension(pVNetRoot)      \
  33.          (((pVNetRoot) == NULL) ? NULL :           \
  34. @@ -3407,10 +3392,6 @@ NTSTATUS nfs41_CreateVNetRoot(
  35.  #ifdef DEBUG_MOUNT
  36.      DbgP("Saving new session 0x%x\n", pVNetRootContext->session);
  37.  #endif
  38. -#ifdef STORE_MOUNT_SEC_CONTEXT
  39. -    status = nfs41_get_sec_ctx(SecurityImpersonation,
  40. -        &pVNetRootContext->mount_sec_ctx);
  41. -#endif
  42.  
  43.  out_free:
  44.      RxFreePool(Config);
  45. @@ -3609,15 +3590,6 @@ NTSTATUS nfs41_FinalizeVNetRoot(
  46.      if (pVNetRoot->pNetRoot->Type != NET_ROOT_DISK &&
  47.              pVNetRoot->pNetRoot->Type != NET_ROOT_WILD)
  48.          status = STATUS_NOT_SUPPORTED;
  49. -#ifdef STORE_MOUNT_SEC_CONTEXT
  50. -    else if (pVNetRootContext->session != INVALID_HANDLE_VALUE) {
  51. -#ifdef DEBUG_MOUNT
  52. -        DbgP("nfs41_FinalizeVNetRoot: deleting security context: %p\n",
  53. -            pVNetRootContext->mount_sec_ctx.ClientToken);
  54. -#endif
  55. -        SeDeleteClientSecurity(&pVNetRootContext->mount_sec_ctx);
  56. -    }
  57. -#endif
  58.  #ifdef DEBUG_MOUNT
  59.      DbgEx();
  60.  #endif
  61. @@ -3913,11 +3885,7 @@ NTSTATUS nfs41_Create(
  62.      status = check_nfs41_create_args(RxContext);
  63.      if (status) goto out;
  64.  
  65. -#if defined(STORE_MOUNT_SEC_CONTEXT) && defined (USE_MOUNT_SEC_CONTEXT)
  66. -    status = nfs41_UpcallCreate(NFS41_OPEN, &pVNetRootContext->mount_sec_ctx,
  67. -#else
  68.      status = nfs41_UpcallCreate(NFS41_OPEN, NULL,
  69. -#endif
  70.          pVNetRootContext->session, INVALID_HANDLE_VALUE,
  71.          pNetRootContext->nfs41d_version,
  72.          SrvOpen->pAlreadyPrefixedName, &entry);
  73. @@ -3980,12 +3948,12 @@ retry_on_link:
  74.      }
  75.  
  76.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  77. -#ifndef USE_MOUNT_SEC_CONTEXT
  78. +
  79.      if (entry->psec_ctx == &entry->sec_ctx) {
  80.          SeDeleteClientSecurity(entry->psec_ctx);
  81.      }
  82.      entry->psec_ctx = NULL;
  83. -#endif
  84. +
  85.      if (status) goto out;
  86.  
  87.      if (entry->u.Open.EaMdl) {
  88. @@ -4077,13 +4045,12 @@ retry_on_link:
  89.  #endif
  90.      nfs41_fobx = (PNFS41_FOBX)(RxContext->pFobx)->Context;
  91.      nfs41_fobx->nfs41_open_state = entry->open_state;
  92. -#ifndef USE_MOUNT_SEC_CONTEXT
  93. +
  94.      status = nfs41_get_sec_ctx(SecurityImpersonation, &nfs41_fobx->sec_ctx);
  95.      if (status)
  96.          goto out_free;
  97. -#else
  98. -    RtlCopyMemory(&nfs41_fobx->sec_ctx, &pVNetRootContext->mount_sec_ctx,
  99. -        sizeof(nfs41_fobx->sec_ctx));
  100. +#if 1
  101. +    ObReferenceObject(nfs41_fobx->sec_ctx.ClientToken);
  102.  #endif
  103.  
  104.      // we get attributes only for data access and file (not directories)
  105. @@ -4384,9 +4351,17 @@ NTSTATUS nfs41_CloseSrvOpen(
  106.          entry->u.Close.renamed = nfs41_fcb->Renamed;
  107.  
  108.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  109. -#ifndef USE_MOUNT_SEC_CONTEXT
  110. +
  111. +#if 1
  112. +    if (!RxContext->pFcb->OpenCount) {
  113. +        ObDereferenceObject(nfs41_fobx->sec_ctx.ClientToken);
  114. +        SeDeleteClientSecurity(&nfs41_fobx->sec_ctx);
  115. +        nfs41_fobx->sec_ctx.ClientToken = NULL;
  116. +    }
  117. +#else
  118.      SeDeleteClientSecurity(&nfs41_fobx->sec_ctx);
  119.  #endif
  120. +
  121.      if (status) goto out;
  122.  
  123.      /* map windows ERRORs to NTSTATUS */
  124. @@ -7179,6 +7154,12 @@ VOID fcbopen_main(PVOID ctx)
  125.                  cur->ChangeTime, cur->skip);
  126.  #endif
  127.              if (cur->skip) goto out;
  128. +
  129. +#if 1
  130. +            if (cur->nfs41_fobx->sec_ctx.ClientToken == NULL) {
  131. +                goto out;
  132. +            }
  133. +#endif
  134.              pNetRootContext =
  135.                  NFS41GetNetRootExtension(cur->fcb->pNetRoot);
  136.              /* place an upcall for this srv_open */

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