pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for sparse support, READ_PLUS hole crash, increase r/w buffer size, tests+misc, 2025-04-07
Posted by Anonymous on Mon 7th Apr 2025 21:18
raw | new post

  1. From eea848a0bc2e8b9d5ba7de6465b3a09ba6ea67b0 Mon Sep 17 00:00:00 2001
  2. From: Cedric Blancher <cedric.blancher@gmail.com>
  3. Date: Mon, 7 Apr 2025 15:17:59 +0200
  4. Subject: [PATCH 1/8] sys: Allow nfs_mount with rsize=/wsize= up to 16MB
  5.  
  6. Allow nfs_mount with rsize=/wsize= up to 16MB.
  7. Default is still 1MB.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. sys/nfs41sys_driver.h | 4 ++--
  12.  1 file changed, 2 insertions(+), 2 deletions(-)
  13.  
  14. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  15. index 496387c..7b3045d 100644
  16. --- a/sys/nfs41sys_driver.h
  17. +++ b/sys/nfs41sys_driver.h
  18. @@ -295,8 +295,8 @@ nfs41_updowncall_list upcall, downcall;
  19.  
  20.  #define SERVER_NAME_BUFFER_SIZE         1024
  21.  #define MOUNT_CONFIG_RW_SIZE_MIN        1024
  22. -#define MOUNT_CONFIG_RW_SIZE_DEFAULT    1048576
  23. -#define MOUNT_CONFIG_RW_SIZE_MAX        1048576
  24. +#define MOUNT_CONFIG_RW_SIZE_DEFAULT    (1*1024*1024)
  25. +#define MOUNT_CONFIG_RW_SIZE_MAX        (16*1024*1024)
  26.  #define MAX_SEC_FLAVOR_LEN              12
  27.  #define UPCALL_TIMEOUT_DEFAULT          50  /* in seconds */
  28.  
  29. --
  30. 2.45.1
  31.  
  32. From 0d6917fed806e21c39db66c85c78a7f6e6ca0a57 Mon Sep 17 00:00:00 2001
  33. From: Cedric Blancher <cedric.blancher@gmail.com>
  34. Date: Mon, 7 Apr 2025 15:25:03 +0200
  35. Subject: [PATCH 2/8] sys: Increase minimum rsize=/wsize= limit to 8192
  36.  
  37. Increase minimum rsize=/wsize= limit to 8192, to make sure it
  38. can fit a full 4096byte long path.
  39.  
  40. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  41. ---
  42. sys/nfs41sys_driver.h | 2 +-
  43.  1 file changed, 1 insertion(+), 1 deletion(-)
  44.  
  45. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  46. index 7b3045d..d086d2e 100644
  47. --- a/sys/nfs41sys_driver.h
  48. +++ b/sys/nfs41sys_driver.h
  49. @@ -294,7 +294,7 @@ nfs41_updowncall_list upcall, downcall;
  50.  
  51.  
  52.  #define SERVER_NAME_BUFFER_SIZE         1024
  53. -#define MOUNT_CONFIG_RW_SIZE_MIN        1024
  54. +#define MOUNT_CONFIG_RW_SIZE_MIN        8192
  55.  #define MOUNT_CONFIG_RW_SIZE_DEFAULT    (1*1024*1024)
  56.  #define MOUNT_CONFIG_RW_SIZE_MAX        (16*1024*1024)
  57.  #define MAX_SEC_FLAVOR_LEN              12
  58. --
  59. 2.45.1
  60.  
  61. From 70111ace6a8fbe3d6f55b3bdde3046dada3ae10b Mon Sep 17 00:00:00 2001
  62. From: Roland Mainz <roland.mainz@nrubsig.org>
  63. Date: Mon, 7 Apr 2025 17:10:41 +0200
  64. Subject: [PATCH 3/8] daemon: Crash in |decode_read_plus_res_ok()| when
  65.  |NFS4_CONTENT_HOLE| hole size exceeds supplied buffer size
  66.  
  67. Crash in |decode_read_plus_res_ok()| when |NFS4_CONTENT_HOLE| hole size
  68. exceeds supplied buffer size.
  69.  
  70. Stack trace looks like this:
  71. ---- snip ----
  72. nfsd!decode_read_plus_res_ok(struct __rpc_xdr * xdr = 0x000001f5`f9e47f30, struct __nfs42_read_plus_res_ok * res = 0x0000006c`1f1fa3a8)+0x555 [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs42_xdr.c @ 233]
  73. nfsd!decode_op_read_plus(struct __rpc_xdr * xdr = 0x000001f5`f9e47f30, struct __nfs_resop4 * resop = 0x0000006c`1f1fa310)+0x6d [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs42_xdr.c @ 263]
  74. nfsd!nfs_decode_compound(struct __rpc_xdr * xdr = 0x000001f5`f9e47f30, char ** pres = 0x0000006c`1f1f9e98)+0x242 [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_xdr.c @ 3778]
  75. libtirpc!authunix_unwrap(struct __auth * auth = 0x000001f5`f9834740, struct __rpc_xdr * xdrs = 0x000001f5`f9e47f30, <function> * func = 0x00007ff6`ef3066bd, char * args = 0x0000006c`1f1f9e98 "", unsigned int seq = 0xffffffff)+0x29 [msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\auth_unix.c @ 392]
  76. libtirpc!clnt_vc_call(struct __rpc_client * cl = 0x000001f5`f9e20950, unsigned int proc = 1, <function> * xdr_args = 0x00007ff6`ef30686b, void * args_ptr = 0x0000006c`1f1f9a80, <function> * xdr_results = 0x00007ff6`ef3066bd, void * results_ptr = 0x0000006c`1f1f9e98, struct timeval timeout = struct timeval)+0x8e3 [msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c @ 738]
  77. nfsd!nfs41_send_compound(struct __nfs41_rpc_clnt * rpc = 0x000001f5`f9e47720, char * inbuf = 0x0000006c`1f1f9a80 ".", char * outbuf = 0x0000006c`1f1f9e98 "")+0xb1 [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_rpc.c @ 366]
  78. nfsd!compound_encode_send_decode(struct __nfs41_session * session = 0x000001f5`f986bee0, struct __nfs41_compound * compound = 0x0000006c`1f1f9a80, int try_recovery = 0n1)+0xdb [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_compound.c @ 173]
  79. nfsd!nfs42_read_plus(struct __nfs41_session * session = 0x000001f5`f986bee0, struct __nfs41_path_fh * file = 0x000001f5`f9e39140, struct __stateid_arg * stateid = 0x0000006c`1f1fa628, unsigned int64 offset = 0xd000, unsigned int count = 0x4000, unsigned char * data_out = 0x000001f5`fd300000 "", unsigned int * data_len_out = 0x0000006c`1f1fa59c, int * eof_out = 0x0000006c`1f1fa57c)+0x16d [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs42_ops.c @ 235]
  80. nfsd!read_from_mds(struct __nfs41_upcall * upcall = 0x0000006c`1f1fe7a0, struct __stateid_arg * stateid = 0x0000006c`1f1fa628)+0x165 [msnfs41_uidmapping\ms-nfs41-client\daemon\readwrite.c @ 82]
  81. nfsd!handle_read(void * daemon_context = 0x00007ff6`ef392010, struct __nfs41_upcall * upcall = 0x0000006c`1f1fe7a0)+0xd2 [msnfs41_uidmapping\ms-nfs41-client\daemon\readwrite.c @ 183]
  82. nfsd!upcall_handle(void * daemon_context = 0x00007ff6`ef392010, struct __nfs41_upcall * upcall = 0x0000006c`1f1fe7a0)+0x77 [msnfs41_uidmapping\ms-nfs41-client\daemon\upcall.c @ 227]
  83. nfsd!nfsd_worker_thread_main(void * args = 0x00007ff6`ef392010)+0x248 [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c @ 207]
  84. nfsd!nfsd_thread_main(void * args = 0x00007ff6`ef392010)+0x1f [msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c @ 245]
  85. ucrtbased!invoke_thread_procedure(<function> * procedure = 0x00007ff6`ef3379b0, void * context = 0x00007ff6`ef392010)+0x2c [d:\th\minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 92]
  86. ucrtbased!thread_start<unsigned int (void * parameter = 0x000001f5`f985b090)+0x93 [d:\th\minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 115]
  87. KERNEL32!BaseThreadInitThunk+0x14
  88. ntdll!RtlUserThreadStart+0x21
  89. ---- snip ----
  90.  
  91. The returned |NFS4_CONTENT_HOLE| hole size in this case is much
  92. bigger than the destination buffer (the NFSv4.2 RFC specifies that
  93. OP_READ_PLUS must return the full size of the hole, and not clamp
  94. it to the buffer size - the NFS client has to do that), causing the
  95. |memset(buffer, 0, hole_size)| to write beyond the buffers end.
  96. Fix is do clamp the |hole_length| that the |memset()| fits into the
  97. destination buffer.
  98.  
  99. Seen with
  100. msnfs41client_cygwin_64bit32bit_binaries_20250331_22h33m_gitbf8d343
  101. with a Linux 5.10.0-22-amd64 nfsd woth commercial software (sparse
  102. file *.exe).
  103.  
  104. Issue can be replicated with tests/sparsefiles/testsparsefile1.ksh
  105.  
  106. Reported-by: Sebastian Feld <sebastian.n.feld@gmail.com>
  107. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  108. ---
  109. daemon/nfs42_xdr.c | 5 ++++-
  110.  1 file changed, 4 insertions(+), 1 deletion(-)
  111.  
  112. diff --git a/daemon/nfs42_xdr.c b/daemon/nfs42_xdr.c
  113. index c3367be..ad82d20 100644
  114. --- a/daemon/nfs42_xdr.c
  115. +++ b/daemon/nfs42_xdr.c
  116. @@ -226,10 +226,13 @@ static bool_t decode_read_plus_res_ok(
  117.                   */
  118.                  if (((hole_buff - res->data) + hole_length) >
  119.                      res->data_len) {
  120. -                    hole_length = res->data_len;
  121. +                    hole_length = res->data_len -
  122. +                        (hole_buff - res->data);
  123.                  }
  124.  
  125.                  EASSERT(hole_length < UINT_MAX);
  126. +                EASSERT(((hole_buff - res->data) + hole_length) <=
  127. +                    res->data_len);
  128.                  (void)memset(hole_buff, 0, (size_t)hole_length);
  129.  
  130.                  read_data_len = __max(read_data_len,
  131. --
  132. 2.45.1
  133.  
  134. From 429a2b9b18258922f120a2b49e24e8f2af51e3a5 Mon Sep 17 00:00:00 2001
  135. From: Roland Mainz <roland.mainz@nrubsig.org>
  136. Date: Mon, 7 Apr 2025 17:42:47 +0200
  137. Subject: [PATCH 4/8] daemon: |decode_read_plus_res_ok()| should not print
  138.  "'NFS4_CONTENT_HOLE' content" debug messages by default
  139.  
  140. |decode_read_plus_res_ok()| should not print "'NFS4_CONTENT_HOLE'
  141. content" debug messages by default.
  142.  
  143. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  144. ---
  145. daemon/nfs42_xdr.c | 5 ++++-
  146.  1 file changed, 4 insertions(+), 1 deletion(-)
  147.  
  148. diff --git a/daemon/nfs42_xdr.c b/daemon/nfs42_xdr.c
  149. index ad82d20..316d03d 100644
  150. --- a/daemon/nfs42_xdr.c
  151. +++ b/daemon/nfs42_xdr.c
  152. @@ -175,6 +175,9 @@ static bool_t decode_read_plus_res_ok(
  153.  
  154.          switch(co) {
  155.              case NFS4_CONTENT_DATA:
  156. +                DPRINTF(2,
  157. +                    ("i=%d, 'NFS4_CONTENT_DATA' content\n", (int)i));
  158. +
  159.                  if (!xdr_u_hyper(xdr, &contents[i].u.data.offset)) {
  160.                      DPRINTF(0,
  161.                          ("i=%d, decoding 'offset' failed\n", (int)i));
  162. @@ -207,7 +210,7 @@ static bool_t decode_read_plus_res_ok(
  163.                  unsigned char *hole_buff;
  164.                  uint64_t hole_length;
  165.  
  166. -                DPRINTF(0,
  167. +                DPRINTF(2,
  168.                      ("i=%d, 'NFS4_CONTENT_HOLE' content\n", (int)i));
  169.                  if (!xdr_u_hyper(xdr, &contents[i].u.hole.offset))
  170.                      return FALSE;
  171. --
  172. 2.45.1
  173.  
  174. From 5d024f96ace8c3209a68468d3eab063c4d09c6c6 Mon Sep 17 00:00:00 2001
  175. From: Roland Mainz <roland.mainz@nrubsig.org>
  176. Date: Mon, 7 Apr 2025 17:45:12 +0200
  177. Subject: [PATCH 5/8] daemon: Fix compiler warning in
  178.  |decode_read_plus_res_ok()|
  179.  
  180. Fix compiler warning in |decode_read_plus_res_ok()|.
  181.  
  182. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  183. ---
  184. daemon/nfs42_xdr.c | 4 ++++
  185.  1 file changed, 4 insertions(+)
  186.  
  187. diff --git a/daemon/nfs42_xdr.c b/daemon/nfs42_xdr.c
  188. index 316d03d..12d133b 100644
  189. --- a/daemon/nfs42_xdr.c
  190. +++ b/daemon/nfs42_xdr.c
  191. @@ -175,6 +175,7 @@ static bool_t decode_read_plus_res_ok(
  192.  
  193.          switch(co) {
  194.              case NFS4_CONTENT_DATA:
  195. +            {
  196.                  DPRINTF(2,
  197.                      ("i=%d, 'NFS4_CONTENT_DATA' content\n", (int)i));
  198.  
  199. @@ -205,8 +206,10 @@ static bool_t decode_read_plus_res_ok(
  200.                  read_data_len = __max(read_data_len,
  201.                      ((size_t)(contents[i].u.data.data - res->data) +
  202.                          contents[i].u.data.data_len));
  203. +            }
  204.                  break;
  205.              case NFS4_CONTENT_HOLE:
  206. +            {
  207.                  unsigned char *hole_buff;
  208.                  uint64_t hole_length;
  209.  
  210. @@ -240,6 +243,7 @@ static bool_t decode_read_plus_res_ok(
  211.  
  212.                  read_data_len = __max(read_data_len,
  213.                      ((hole_buff - res->data) + hole_length));
  214. +            }
  215.                  break;
  216.              default:
  217.                  eprintf("decode_read_plus_res_ok: unknown co=%d\n",
  218. --
  219. 2.45.1
  220.  
  221. From 4e4dae97efe9ef3878cc0d6f5433c601e2dcce0e Mon Sep 17 00:00:00 2001
  222. From: Roland Mainz <roland.mainz@nrubsig.org>
  223. Date: Mon, 7 Apr 2025 18:23:42 +0200
  224. Subject: [PATCH 6/8] sys: RFE: Increase default rsize=/wsize= value to 4MB
  225.  
  226. RFE: Increase default rsize=/wsize= value to 4MB
  227.  
  228. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  229. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  230. ---
  231. sys/nfs41sys_driver.h | 2 +-
  232.  1 file changed, 1 insertion(+), 1 deletion(-)
  233.  
  234. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  235. index d086d2e..c671625 100644
  236. --- a/sys/nfs41sys_driver.h
  237. +++ b/sys/nfs41sys_driver.h
  238. @@ -295,7 +295,7 @@ nfs41_updowncall_list upcall, downcall;
  239.  
  240.  #define SERVER_NAME_BUFFER_SIZE         1024
  241.  #define MOUNT_CONFIG_RW_SIZE_MIN        8192
  242. -#define MOUNT_CONFIG_RW_SIZE_DEFAULT    (1*1024*1024)
  243. +#define MOUNT_CONFIG_RW_SIZE_DEFAULT    (4*1024*1024)
  244.  #define MOUNT_CONFIG_RW_SIZE_MAX        (16*1024*1024)
  245.  #define MAX_SEC_FLAVOR_LEN              12
  246.  #define UPCALL_TIMEOUT_DEFAULT          50  /* in seconds */
  247. --
  248. 2.45.1
  249.  
  250. From 8df76fc31bc7815ce0bc6bb4425454f631f15e72 Mon Sep 17 00:00:00 2001
  251. From: Roland Mainz <roland.mainz@nrubsig.org>
  252. Date: Mon, 7 Apr 2025 19:18:18 +0200
  253. Subject: [PATCH 7/8] tests: testsparseexe1.ksh should test *.exe checksums
  254.  before/after cp
  255.  
  256. testsparseexe1.ksh should test *.exe checksums before/after cp,
  257. the checksums should be identical since only sequences of 0x00-bytes
  258. are turned into holes, and holes read as 0x00 bytes.
  259.  
  260. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  261. ---
  262. tests/sparsefiles/testsparseexe1.ksh | 13 +++++++++++++
  263.  1 file changed, 13 insertions(+)
  264.  
  265. diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
  266. index 9eebed5..87f4eab 100644
  267. --- a/tests/sparsefiles/testsparseexe1.ksh
  268. +++ b/tests/sparsefiles/testsparseexe1.ksh
  269. @@ -114,6 +114,8 @@ function test_sparseexe1
  270.      integer res.sparseexe_sparse_blocks=$(stat --printf '%b\n' 'sparseexe_sparse.exe')
  271.      integer res.sparseexe_orig_filesize=$(stat --printf '%s\n' 'sparseexe_orig.exe')
  272.      integer res.sparseexe_sparse_filesize=$(stat --printf '%s\n' 'sparseexe_sparse.exe')
  273. +    typeset res.sparseexe_orig_md5hash=$(md5sum --total 'sparseexe_orig.exe')
  274. +    typeset res.sparseexe_sparse_md5hash=$(md5sum --total '%s\n' 'sparseexe_sparse.exe')
  275.  
  276.      compound res.testrun=(
  277.          typeset stderr=''
  278. @@ -164,6 +166,16 @@ function test_sparseexe1
  279.          (( res.errors++ ))
  280.      fi
  281.  
  282. +    if [[ "${res.sparseexe_orig_md5hash}" == "${res.sparseexe_sparse_md5hash}" ]] ; then
  283. +        printf 'test file MD5 hash sum: OK, both hash sums are identical (%q)\n' \
  284. +            "${res.sparseexe_sparse_md5hash}"
  285. +    else
  286. +        printf '# ERROR: MD5 hash sums are NOT identical (%q != %q)\n' \
  287. +            "${res.sparseexe_orig_md5hash}" \
  288. +            "${res.sparseexe_sparse_md5hash}"
  289. +        (( res.errors++ ))
  290. +    fi
  291. +
  292.      if (( res.errors == 0 )) ; then
  293.          printf '#### %s: All tests OK\n' "$0"
  294.          exit 0
  295. @@ -180,6 +192,7 @@ function test_sparseexe1
  296.  #
  297.  builtin cat
  298.  builtin rm
  299. +builtin md5sum || exit 1 # need AST md5sum for option --total
  300.  
  301.  test_sparseexe1
  302.  
  303. --
  304. 2.45.1
  305.  
  306. From d8da6e8dbdb3bc58a7da4ddaa759a98b579683b4 Mon Sep 17 00:00:00 2001
  307. From: Roland Mainz <roland.mainz@nrubsig.org>
  308. Date: Mon, 7 Apr 2025 19:28:55 +0200
  309. Subject: [PATCH 8/8] tests: testsparseexe1.ksh minor cleanup
  310.  
  311. testsparseexe1.ksh minor cleanup
  312.  
  313. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  314. ---
  315. tests/sparsefiles/testsparseexe1.ksh | 8 ++++----
  316.  1 file changed, 4 insertions(+), 4 deletions(-)
  317.  
  318. diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
  319. index 87f4eab..b2c2a42 100644
  320. --- a/tests/sparsefiles/testsparseexe1.ksh
  321. +++ b/tests/sparsefiles/testsparseexe1.ksh
  322. @@ -98,12 +98,12 @@ function test_sparseexe1
  323.      # /usr/bin/cp.exe has sparse file support (which depends on
  324.      # SEEK_HOLE+SEEK_DATA.
  325.      #
  326. -    if which -a 'fallocate.exe' 2>'/dev/null' ; then
  327. -        print $'# copy *.exe via cp --sparse=always, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  328. +    if which -a 'fallocate.exe' 1>'/dev/null' ; then
  329. +        print $'# copy *.exe via cp --sparse=always, turn all sections with long sequences of 0x00-bytes into "holes" ...'
  330.          # explicitly use /usr/bin/cp and not the AST cp builtin
  331.          /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
  332.      else
  333. -        print $'# copy *.exe via dd conv=sparse, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  334. +        print $'# copy *.exe via dd conv=sparse, turn all sections with long sequences of 0x00-bytes into "holes" ...'
  335.          # explicitly use /usr/bin/cp and not the AST cp builtin
  336.          dd if='sparseexe_orig.exe' of='sparseexe_sparse.exe' conv=sparse
  337.          chmod a+x 'sparseexe_sparse.exe'
  338. @@ -115,7 +115,7 @@ function test_sparseexe1
  339.      integer res.sparseexe_orig_filesize=$(stat --printf '%s\n' 'sparseexe_orig.exe')
  340.      integer res.sparseexe_sparse_filesize=$(stat --printf '%s\n' 'sparseexe_sparse.exe')
  341.      typeset res.sparseexe_orig_md5hash=$(md5sum --total 'sparseexe_orig.exe')
  342. -    typeset res.sparseexe_sparse_md5hash=$(md5sum --total '%s\n' 'sparseexe_sparse.exe')
  343. +    typeset res.sparseexe_sparse_md5hash=$(md5sum --total 'sparseexe_sparse.exe')
  344.  
  345.      compound res.testrun=(
  346.          typeset stderr=''
  347. --
  348. 2.45.1

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