pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: Patch, Experiments 2023-11-13
Posted by Anonymous on Tue 14th Nov 2023 09:53
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/mount.c b/daemon/mount.c
  85. index a7b3a8c..853c55f 100644
  86. --- a/daemon/mount.c
  87. +++ b/daemon/mount.c
  88. @@ -73,8 +73,8 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
  89.  
  90.      if ((args->path == NULL) || (strlen(args->path) == 0)) {
  91.          eprintf("handle_mount: empty mount root\n");
  92. -        status = ERROR_BAD_NETPATH;
  93. -        goto out;
  94. +//        status = ERROR_BAD_NETPATH;
  95. +//        goto out;
  96.      }
  97.  
  98.      (void)strcpy_s(hostname, sizeof(hostname), args->hostport);
  99. diff --git a/daemon/open.c b/daemon/open.c
  100. index 4b2a335..cba7737 100644
  101. --- a/daemon/open.c
  102. +++ b/daemon/open.c
  103. @@ -99,6 +99,24 @@ static void open_state_free(
  104.  void nfs41_open_state_ref(
  105.      IN nfs41_open_state *state)
  106.  {
  107. +#if 1
  108. +    /*
  109. +     * gisburn: fixme: sometimes this happens under high parallel
  110. +     * usage with multiple mounts - but why ?
  111. +     * 0:038> kp
  112. +     * Child-SP          RetAddr           Call Site
  113. +     * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
  114. +     * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
  115. +     * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
  116. +     * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
  117. +     * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
  118. +     * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
  119. +     */
  120. +    EASSERT(state != NULL);
  121. +    if (state == NULL)
  122. +        return;
  123. +#endif
  124. +
  125.      const LONG count = InterlockedIncrement(&state->ref_count);
  126.  
  127.      dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
  128. diff --git a/daemon/upcall.c b/daemon/upcall.c
  129. index bd13c61..1cdcb18 100644
  130. --- a/daemon/upcall.c
  131. +++ b/daemon/upcall.c
  132. @@ -45,7 +45,9 @@ extern const nfs41_upcall_op nfs41_op_volume;
  133.  extern const nfs41_upcall_op nfs41_op_getacl;
  134.  extern const nfs41_upcall_op nfs41_op_setacl;
  135.  
  136. +/* keep in sync with nfs41_opcodes in sys/nfs41_driver.h */
  137.  static const nfs41_upcall_op *g_upcall_op_table[] = {
  138. +    NULL,
  139.      &nfs41_op_mount,
  140.      &nfs41_op_unmount,
  141.      &nfs41_op_open,
  142. @@ -63,7 +65,9 @@ static const nfs41_upcall_op *g_upcall_op_table[] = {
  143.      &nfs41_op_volume,
  144.      &nfs41_op_getacl,
  145.      &nfs41_op_setacl,
  146. -    NULL,
  147. +    NULL, /* reserved */
  148. +    NULL, /* reserved */
  149. +    NULL, /* reserved */
  150.      NULL
  151.  };
  152.  static const uint32_t g_upcall_op_table_size = ARRAYSIZE(g_upcall_op_table);
  153. @@ -121,6 +125,7 @@ int upcall_parse(
  154.      /* parse the operation's arguments */
  155.      op = g_upcall_op_table[upcall->opcode];
  156.      if (op && op->parse) {
  157. +        EASSERT(length > 0);
  158.          status = op->parse(buffer, length, upcall);
  159.          if (status) {
  160.              eprintf("parsing of upcall '%s' failed with %d.\n",
  161. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  162. index 8b259bb..0b3de6e 100644
  163. --- a/dll/nfs41_np.c
  164. +++ b/dll/nfs41_np.c
  165. @@ -329,6 +329,7 @@ NPGetCaps(
  166.              break;
  167.  
  168.          case WNNC_NET_TYPE:
  169. +            /* gisburn: should be WNNC_NET_*NFS* */
  170.              rc = WNNC_NET_RDR2SAMPLE;
  171.              break;
  172.  
  173. @@ -344,7 +345,7 @@ NPGetCaps(
  174.              break;
  175.  
  176.          case WNNC_ENUMERATION:
  177. -            rc = WNNC_ENUM_LOCAL;
  178. +            rc = WNNC_ENUM_GLOBAL/*WNNC_ENUM_LOCAL*/;
  179.              break;
  180.  
  181.          case WNNC_START:
  182. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  183. index 93ee7a9..d43334a 100644
  184. --- a/sys/nfs41_build_features.h
  185. +++ b/sys/nfs41_build_features.h
  186. @@ -32,19 +32,19 @@
  187.  /*
  188.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  189.   */
  190. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  191. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  192.  
  193.  /*
  194.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  195.   * files which do not map to a local account a SID in the
  196.   * Unix_User+x/Unix_Group+x range
  197.   */
  198. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  199. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  200.  
  201.  /*
  202.   * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
  203.   * as "name service"
  204.   */
  205. -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  206. +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
  207.  
  208.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  209. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  210. index 97f6445..0f80e5e 100644
  211. --- a/sys/nfs41_driver.c
  212. +++ b/sys/nfs41_driver.c
  213. @@ -1329,7 +1329,16 @@ NTSTATUS handle_upcall(
  214.      ULONG cbOut = LowIoContext->ParamsFor.IoCtl.OutputBufferLength;
  215.      unsigned char *pbOut = LowIoContext->ParamsFor.IoCtl.pOutputBuffer;
  216.  
  217. +    __try {
  218.          status = SeImpersonateClientEx(entry->psec_ctx, NULL);
  219. +    } __except(EXCEPTION_EXECUTE_HANDLER) {
  220. +        NTSTATUS code;
  221. +        code = GetExceptionCode();
  222. +        print_error("Call to SeImpersonateClientEx() failed due to"
  223. +            " exception 0x%0x\n", code);
  224. +        status = STATUS_ACCESS_DENIED;
  225. +    }
  226. +
  227.      if (status != STATUS_SUCCESS) {
  228.          print_error("SeImpersonateClientEx failed %x\n", status);
  229.          goto out;
  230. @@ -2832,9 +2841,10 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  231.                  RtlCopyUnicodeString(&Config->SecFlavor, &usValue);
  232.          }
  233.          else {
  234. -            status = STATUS_INVALID_PARAMETER;
  235. -            print_error("Unrecognized option '%ls' -> '%wZ'\n",
  236. -                Name, usValue);
  237. +            //status = STATUS_INVALID_PARAMETER;
  238. +            print_error("Unrecognized option '%ls' -> '%wZ' Option->NextEntryOffset=%ld\n",
  239. +                Name, usValue, (long)Option->NextEntryOffset);
  240. +            break;
  241.          }
  242.  
  243.          if (Option->NextEntryOffset == 0)
  244. diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
  245. index f11eda8..0525eaa 100644
  246. --- a/sys/nfs41_driver.h
  247. +++ b/sys/nfs41_driver.h
  248. @@ -49,26 +49,27 @@
  249.  #define IOCTL_NFS41_WRITE       _RDR_CTL_CODE(7, METHOD_BUFFERED)
  250.  #define IOCTL_NFS41_INVALCACHE  _RDR_CTL_CODE(8, METHOD_BUFFERED)
  251.  
  252. +/* keep in sync with g_upcall_op_table in daemon/upcall.c */
  253.  typedef enum _nfs41_opcodes {
  254. -    NFS41_MOUNT,
  255. -    NFS41_UNMOUNT,
  256. -    NFS41_OPEN,
  257. -    NFS41_CLOSE,
  258. -    NFS41_READ,
  259. -    NFS41_WRITE,
  260. -    NFS41_LOCK,
  261. -    NFS41_UNLOCK,
  262. -    NFS41_DIR_QUERY,
  263. -    NFS41_FILE_QUERY,
  264. -    NFS41_FILE_SET,
  265. -    NFS41_EA_GET,
  266. -    NFS41_EA_SET,
  267. -    NFS41_SYMLINK,
  268. -    NFS41_VOLUME_QUERY,
  269. -    NFS41_ACL_QUERY,
  270. -    NFS41_ACL_SET,
  271. -    NFS41_SHUTDOWN,
  272. -    INVALID_OPCODE
  273. +    INVALID_NULL_OPCODE = 0,
  274. +    NFS41_MOUNT = 1,
  275. +    NFS41_UNMOUNT = 2,
  276. +    NFS41_OPEN = 3,
  277. +    NFS41_CLOSE = 4,
  278. +    NFS41_READ = 5,
  279. +    NFS41_WRITE = 6,
  280. +    NFS41_LOCK = 7,
  281. +    NFS41_UNLOCK = 8,
  282. +    NFS41_DIR_QUERY = 9,
  283. +    NFS41_FILE_QUERY = 10,
  284. +    NFS41_FILE_SET = 11,
  285. +    NFS41_EA_GET = 12,
  286. +    NFS41_EA_SET = 13,
  287. +    NFS41_SYMLINK = 14,
  288. +    NFS41_VOLUME_QUERY = 15,
  289. +    NFS41_ACL_QUERY = 16,
  290. +    NFS41_ACL_SET = 17,
  291. +    NFS41_SHUTDOWN = 18
  292.  } nfs41_opcodes;
  293.  
  294.  enum rpcsec_flavors {

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