pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfa41client: Patches for DrMemory hits, assert_msg()+misc, 2024-05-03
Posted by Anonymous on Fri 3rd May 2024 15:27
raw | new post

  1. From 5b7b4961d95f809a27954d169c70ec58645ef5c3 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 3 May 2024 10:11:22 +0200
  4. Subject: [PATCH 1/6] cygwin: Fix drmemory support in msnfs41client
  5.  sys_run_daemon
  6.  
  7. Fix DrMemory support in $ bash ./msnfs41client sys_run_daemon #
  8. (function "nfsclient_system_rundeamon")
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. cygwin/devel/msnfs41client.bash | 35 ++++++++++++++++++++++++++-------
  13.  1 file changed, 28 insertions(+), 7 deletions(-)
  14.  
  15. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  16. index 41a2b4f..744b550 100644
  17. --- a/cygwin/devel/msnfs41client.bash
  18. +++ b/cygwin/devel/msnfs41client.bash
  19. @@ -279,12 +279,6 @@ function nfsclient_system_rundeamon
  20.                 #'--gid' '1616' '--uid' '1616'
  21.         )
  22.  
  23. -       # run everything as su_system
  24. -       nfsd_args=(
  25. -               'su_system'
  26. -               "${nfsd_args[@]}"
  27. -       )
  28. -
  29.         #
  30.         # cdb cheat sheet:
  31.         #
  32. @@ -304,6 +298,13 @@ function nfsclient_system_rundeamon
  33.                         '--args'
  34.                         "${nfsd_args[@]}"
  35.                 )
  36. +
  37. +               # run everything as su_system
  38. +               nfsd_args=(
  39. +                       'su_system'
  40. +                       "${nfsd_args[@]}"
  41. +               )
  42. +
  43.                 "${nfsd_args[@]}"
  44.         elif false ; then
  45.                 export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD");srv*https://msdl.microsoft.com/download/symbols"
  46. @@ -314,6 +315,13 @@ function nfsclient_system_rundeamon
  47.                         "$(cygpath -w "$PWD/${nfsd_args[0]}")"
  48.                         "${nfsd_args[@]:1}"
  49.                 )
  50. +
  51. +               # run everything as su_system
  52. +               nfsd_args=(
  53. +                       'su_system'
  54. +                       "${nfsd_args[@]}"
  55. +               )
  56. +
  57.                 "${nfsd_args[@]}"
  58.         elif false ; then
  59.                 #
  60. @@ -340,10 +348,18 @@ function nfsclient_system_rundeamon
  61.                                 "${nfsd_args[@]}"
  62.                                 '--crtdbgmem' 'none'
  63.                         )
  64. +
  65. +               # run everything as su_system
  66. +               nfsd_args=(
  67. +                       'su_system'
  68. +                       "${nfsd_args[@]}"
  69. +               )
  70. +
  71.                 "${nfsd_args[@]}"
  72.         elif false ; then
  73.                 typeset -i vsdiagnostics_id=50
  74. -               VSDiagnostics \
  75. +               # run everything as su_system
  76. +               su_system VSDiagnostics \
  77.                         start ${vsdiagnostics_id} \
  78.                         "/launch:$(cygpath -w "$PWD/nfsd_debug.exe")" \
  79.                         "/launchArgs:${nfsd_args[*]:1}" \
  80. @@ -354,6 +370,11 @@ function nfsclient_system_rundeamon
  81.                         "$(which -a 'VSDiagnostics.exe')" \
  82.                         "${vsdiagnostics_id}" "$$"
  83.         else
  84. +               # run everything as su_system
  85. +               nfsd_args=(
  86. +                       'su_system'
  87. +                       "${nfsd_args[@]}"
  88. +               )
  89.  
  90.                 "${nfsd_args[@]}"
  91.         fi
  92. --
  93. 2.43.0
  94.  
  95. From 8239b0d14c1500d76817326593805cd0272bf49a Mon Sep 17 00:00:00 2001
  96. From: Roland Mainz <roland.mainz@nrubsig.org>
  97. Date: Fri, 3 May 2024 10:16:28 +0200
  98. Subject: [PATCH 2/6] sys: Use |nfs41_opcodes opcode| instead of |DWORD| to aid
  99.  WinDBG debugging
  100.  
  101. Use |nfs41_opcodes opcode| instead of |DWORD| in
  102. |struct _updowncall_entry| to aid WinDBG debugging.
  103.  
  104. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  105. ---
  106. sys/nfs41_driver.c | 2 +-
  107.  1 file changed, 1 insertion(+), 1 deletion(-)
  108.  
  109. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  110. index 511186c..0378cfe 100644
  111. --- a/sys/nfs41_driver.c
  112. +++ b/sys/nfs41_driver.c
  113. @@ -167,7 +167,7 @@ typedef enum _nfs41_updowncall_state {
  114.  typedef struct _updowncall_entry {
  115.      DWORD version;
  116.      LONGLONG xid;
  117. -    DWORD opcode;
  118. +    nfs41_opcodes opcode;
  119.      NTSTATUS status;
  120.      nfs41_updowncall_state state;
  121.      FAST_MUTEX lock;
  122. --
  123. 2.43.0
  124.  
  125. From 64db3613496e521ba1759bdf7d51c53e9125406a Mon Sep 17 00:00:00 2001
  126. From: Roland Mainz <roland.mainz@nrubsig.org>
  127. Date: Fri, 3 May 2024 10:18:06 +0200
  128. Subject: [PATCH 3/6] daemon: Fix two DrMemory hits in |decode_readdir_entry()|
  129.  
  130. Fix two DrMemory hits in |decode_readdir_entry()|
  131.  
  132. Stack traces for the hits:
  133. ---- snip ----
  134. Error #30: UNINITIALIZED READ: reading 1 byte(s)
  135. replace_memmove                           [D:\a\drmemory\drmemory\drmemory\replace.c:768]
  136. decode_readdir_entry                      [ms-nfs41-client\daemon\nfs41_xdr.c:2347]
  137. decode_readdir_list                       [ms-nfs41-client\daemon\nfs41_xdr.c:2380]
  138. decode_op_readdir                         [ms-nfs41-client\daemon\nfs41_xdr.c:2411]
  139. nfs_decode_compound                       [ms-nfs41-client\daemon\nfs41_xdr.c:3688]
  140. libtirpc.dll!authunix_unwrap              [ms-nfs41-client\libtirpc\src\auth_unix.c:391]
  141. libtirpc.dll!clnt_vc_call                 [ms-nfs41-client\libtirpc\src\clnt_vc.c:689]
  142. nfs41_send_compound                       [ms-nfs41-client\daemon\nfs41_rpc.c:351]
  143. compound_encode_send_decode               [ms-nfs41-client\daemon\nfs41_compound.c:153]
  144. nfs41_readdir                             [ms-nfs41-client\daemon\nfs41_ops.c:1113]
  145. handle_readdir                            [ms-nfs41-client\daemon\readdir.c:750]
  146. upcall_handle                             [ms-nfs41-client\daemon\upcall.c:190]
  147. nfsd_worker_thread_main                   [ms-nfs41-client\daemon\nfs41_daemon.c:176]
  148. nfsd_thread_main                          [ms-nfs41-client\daemon\nfs41_daemon.c:210]
  149. ucrtbased.dll!register_onexit_function   +0x12f    (0x00007ffdbe052d20 <ucrtbased.dll+0xb2d20>)
  150. KERNEL32.dll!BaseThreadInitThunk
  151.  
  152. Error #31: UNINITIALIZED READ: reading 4 byte(s)
  153. replace_memmove                           [D:\a\drmemory\drmemory\drmemory\replace.c:757]
  154. decode_readdir_entry                      [ms-nfs41-client\daemon\nfs41_xdr.c:2347]
  155. decode_readdir_list                       [ms-nfs41-client\daemon\nfs41_xdr.c:2380]
  156. decode_op_readdir                         [ms-nfs41-client\daemon\nfs41_xdr.c:2411]
  157. nfs_decode_compound                       [ms-nfs41-client\daemon\nfs41_xdr.c:3688]
  158. libtirpc.dll!authunix_unwrap              [ms-nfs41-client\libtirpc\src\auth_unix.c:391]
  159. libtirpc.dll!clnt_vc_call                 [ms-nfs41-client\libtirpc\src\clnt_vc.c:689]
  160. nfs41_send_compound                       [ms-nfs41-client\daemon\nfs41_rpc.c:351]
  161. compound_encode_send_decode               [ms-nfs41-client\daemon\nfs41_compound.c:153]
  162. nfs41_readdir                             [ms-nfs41-client\daemon\nfs41_ops.c:1113]
  163. handle_readdir                            [ms-nfs41-client\daemon\readdir.c:750]
  164. upcall_handle                             [ms-nfs41-client\daemon\upcall.c:190]
  165. nfsd_worker_thread_main                   [ms-nfs41-client\daemon\nfs41_daemon.c:176]
  166. nfsd_thread_main                          [ms-nfs41-client\daemon\nfs41_daemon.c:210]
  167. ucrtbased.dll!register_onexit_function   +0x12f    (0x00007ffdbe052d20 <ucrtbased.dll+0xb2d20>)
  168. KERNEL32.dll!BaseThreadInitThunk
  169. ---- snip ----
  170.  
  171. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  172. ---
  173. daemon/nfs41_xdr.c | 2 +-
  174.  1 file changed, 1 insertion(+), 1 deletion(-)
  175.  
  176. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  177. index 1a33d95..e617789 100644
  178. --- a/daemon/nfs41_xdr.c
  179. +++ b/daemon/nfs41_xdr.c
  180. @@ -2304,7 +2304,7 @@ static bool_t decode_readdir_entry(
  181.      unsigned char name[NFS4_OPAQUE_LIMIT];
  182.      unsigned char *nameptr = &name[0];
  183.      uint32_t name_len, entry_len;
  184. -    fattr4 attrs;
  185. +    fattr4 attrs = { 0 };
  186.  
  187.      /* decode into temporaries so we can determine if there's enough
  188.       * room in the buffer for this entry */
  189. --
  190. 2.43.0
  191.  
  192. From d36d55f92f5999c92ea1bf57de532a7bd01216d8 Mon Sep 17 00:00:00 2001
  193. From: Roland Mainz <roland.mainz@nrubsig.org>
  194. Date: Fri, 3 May 2024 14:35:35 +0200
  195. Subject: [PATCH 4/6] daemon: Add |DASSERT_MSG()|+|EASSERT_MSG()| for extra
  196.  assert diagnotics
  197.  
  198. Add |DASSERT_MSG()| and |EASSERT_MSG()| macros to print extra
  199. diagnotics for asserts.
  200.  
  201. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  202. ---
  203. daemon/daemon_debug.c |  9 +++++++++
  204.  daemon/daemon_debug.h | 11 +++++++++++
  205.  2 files changed, 20 insertions(+)
  206.  
  207. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  208. index 183a398..8788d2b 100644
  209. --- a/daemon/daemon_debug.c
  210. +++ b/daemon/daemon_debug.c
  211. @@ -191,6 +191,15 @@ void logprintf(LPCSTR format, ...)
  212.      }
  213.  }
  214.  
  215. +void eprintf_out(LPCSTR format, ...)
  216. +{
  217. +    va_list args;
  218. +    va_start(args, format);
  219. +    (void)vfprintf(elog_file, format, args);
  220. +    (void)fflush(elog_file);
  221. +    va_end(args);
  222. +}
  223. +
  224.  void eprintf(LPCSTR format, ...)
  225.  {
  226.      va_list args;
  227. diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
  228. index 922367a..e28c43e 100644
  229. --- a/daemon/daemon_debug.h
  230. +++ b/daemon/daemon_debug.h
  231. @@ -48,10 +48,20 @@
  232.      if (!(exp)) { \
  233.          eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
  234.              ""#exp"", __FILE__, (long)__LINE__); }
  235. +#define EASSERT_MSG(exp, msg) \
  236. +    if (!(exp)) { \
  237. +        eprintf("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  238. +            ""#exp"", __FILE__, (long)__LINE__); \
  239. +        eprintf_out msg ; }
  240.  #define DASSERT(exp, level) \
  241.      if (!(exp)) { \
  242.          DPRINTF((level), ("ASSERTION '%s' in '%s'/%ld failed.\n", \
  243.              ""#exp"", __FILE__, (long)__LINE__)); }
  244. +#define DASSERT_MSG(exp, level, msg) \
  245. +    if (!(exp) && DPRINTF_LEVEL_ENABLED(level)) { \
  246. +        DPRINTF((level), ("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  247. +            ""#exp"", __FILE__, (long)__LINE__)); \
  248. +        dprintf_out msg ; }
  249.  
  250.  #define DASSERT_IS_VALID_NON_NULL_PTR(exp, level) \
  251.      if (!DEBUG_IS_VALID_NON_NULL_PTR(exp)) { \
  252. @@ -81,6 +91,7 @@ extern int g_debug_level;
  253.  void set_debug_level(int level);
  254.  void logprintf(LPCSTR format, ...);
  255.  void dprintf_out(LPCSTR format, ...);
  256. +void eprintf_out(LPCSTR format, ...);
  257.  void eprintf(LPCSTR format, ...);
  258.  
  259.  void print_windows_access_mask(int on, ACCESS_MASK m);
  260. --
  261. 2.43.0
  262.  
  263. From 6664e6cc88fd39358ed5a42927caaeee2f8c2104 Mon Sep 17 00:00:00 2001
  264. From: Roland Mainz <roland.mainz@nrubsig.org>
  265. Date: Fri, 3 May 2024 14:37:48 +0200
  266. Subject: [PATCH 5/6] daemon: Add assert to |sidcache_add()| to test for empty
  267.  names
  268.  
  269. Add assertion to |sidcache_add()| to test for empty |win32name|
  270. strings.
  271.  
  272. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  273. ---
  274. daemon/sid.c | 2 ++
  275.  1 file changed, 2 insertions(+)
  276.  
  277. diff --git a/daemon/sid.c b/daemon/sid.c
  278. index 7e3f3d4..ea75bba 100644
  279. --- a/daemon/sid.c
  280. +++ b/daemon/sid.c
  281. @@ -215,6 +215,8 @@ void sidcache_add(sidcache *cache, const char* win32name, PSID value)
  282.      ssize_t freeEntryIndex;
  283.      time_t currentTimestamp;
  284.  
  285. +    EASSERT(win32name[0] != '\0');
  286. +
  287.      EnterCriticalSection(&cache->lock);
  288.      currentTimestamp = time(NULL);
  289.  
  290. --
  291. 2.43.0
  292.  
  293. From edd7c931bfc817184470d2350ad3144b2e3e75d5 Mon Sep 17 00:00:00 2001
  294. From: Roland Mainz <roland.mainz@nrubsig.org>
  295. Date: Fri, 3 May 2024 14:40:13 +0200
  296. Subject: [PATCH 6/6] daemon: Fix DrMemory hit in |handle_setacl()| codepath
  297.  
  298. Fix DrMemory hit in |handle_setacl()| codepath, which was
  299. caused by missing error propagation in |map_nfs4ace_who|().
  300.  
  301. DrMemory Stack trace:
  302. ---- snip ----
  303. Error #34: UNINITIALIZED READ: reading 1 byte(s)
  304. replace_strlen              [D:\a\drmemory\drmemory\drmemory\replace.c:406]
  305. encode_file_attrs           [ms-nfs41-client\daemon\nfs41_xdr.c:2646]
  306. encode_op_setattr           [ms-nfs41-client\daemon\nfs41_xdr.c:2697]
  307. nfs_encode_compound         [ms-nfs41-client\daemon\nfs41_xdr.c:3632]
  308. libtirpc.dll!authunix_wrap  [ms-nfs41-client\libtirpc\src\auth_unix.c:385]
  309. libtirpc.dll!clnt_vc_call   [ms-nfs41-client\libtirpc\src\clnt_vc.c:575]
  310. nfs41_send_compound         [ms-nfs41-client\daemon\nfs41_rpc.c:351]
  311. compound_encode_send_decode [ms-nfs41-client\daemon\nfs41_compound.c:153]
  312. nfs41_setattr               [ms-nfs41-client\daemon\nfs41_ops.c:1479]
  313. handle_setacl               [ms-nfs41-client\daemon\acl.c:887]
  314. upcall_handle               [ms-nfs41-client\daemon\upcall.c:190]
  315. nfsd_worker_thread_main     [ms-nfs41-client\daemon\nfs41_daemon.c:176]
  316. ---- snip ----
  317.  
  318. The patch also adds |EASSERT_MSG()| to immediately report
  319. empty |info.owner| and |info.owner_group| strings.
  320.  
  321. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  322. ---
  323. daemon/acl.c | 8 ++++++++
  324.  1 file changed, 8 insertions(+)
  325.  
  326. diff --git a/daemon/acl.c b/daemon/acl.c
  327. index 0802374..13cc81b 100644
  328. --- a/daemon/acl.c
  329. +++ b/daemon/acl.c
  330. @@ -647,6 +647,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
  331.                  DPRINTF(ACLLVL, ("map_nfs4ace_who: LookupAccountSidA() "
  332.                      "returned ERROR_NONE_MAPPED for sidstr='%s'\n",
  333.                      sidstr));
  334. +                status = lasterr;
  335.                  goto out;
  336.              /* Catch other cases */
  337.              case ERROR_NO_SUCH_USER:
  338. @@ -655,6 +656,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
  339.                      "returned ERROR_NO_SUCH_@(USER|GROUP) for "
  340.                      "sidstr='%s'\n",
  341.                      sidstr);
  342. +                status = lasterr;
  343.                  goto out;
  344.              default:
  345.                  eprintf("map_nfs4ace_who: Internal error, "
  346. @@ -821,6 +823,9 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  347.          info.owner = ownerbuf;
  348.          info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  349.          info.attrmask.count = 2;
  350. +
  351. +        EASSERT_MSG(info.owner[0] != '\0',
  352. +            ("info.owner='%s'\n", info.owner));
  353.      }
  354.  
  355.      if (args->query & GROUP_SECURITY_INFORMATION) {
  356. @@ -840,6 +845,9 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  357.          info.owner_group = groupbuf;
  358.          info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  359.          info.attrmask.count = 2;
  360. +
  361. +        EASSERT_MSG(info.owner_group[0] != '\0',
  362. +            ("info.owner_group='%s'\n", info.owner_group));
  363.      }
  364.  
  365.      if (args->query & DACL_SECURITY_INFORMATION) {
  366. --
  367. 2.43.0

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