pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Fixes for |FileNetworkOpenInformation|+test case, syscall buffer mapping kernel error ids+misc, 2024-08-10
Posted by Anonymous on Sat 10th Aug 2024 15:54
raw | new post

  1. From 29a8dc6a7b4c4eb7e448459d915d77f8ce5ee33b Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Sat, 10 Aug 2024 12:29:56 +0200
  4. Subject: [PATCH 1/3] sys: |MmMapLockedPagesSpecifyCache()| exceptions should
  5.  return |STATUS_ACCESS_VIOLATION|
  6.  
  7. |MmMapLockedPagesSpecifyCache()| exceptions should return
  8. |STATUS_ACCESS_VIOLATION|, so users can distinguish it
  9. from normal file access |STATUS_ACCESS_DENIED|.
  10.  
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. sys/nfs41_driver.c | 17 +++++++++++------
  14.  1 file changed, 11 insertions(+), 6 deletions(-)
  15.  
  16. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  17. index eedfe4e..75a76c3 100644
  18. --- a/sys/nfs41_driver.c
  19. +++ b/sys/nfs41_driver.c
  20. @@ -834,7 +834,7 @@ static NTSTATUS marshal_nfs41_open(
  21.          print_error("marshal_nfs41_open: Call to "
  22.              "MmMapLockedPagesSpecifyCache() failed "
  23.              "due to exception 0x%x\n", (int)GetExceptionCode());
  24. -        status = STATUS_ACCESS_DENIED;
  25. +        status = STATUS_ACCESS_VIOLATION;
  26.          goto out;
  27.      }
  28.      RtlCopyMemory(tmp, &entry->u.Open.EaBuffer, sizeof(HANDLE));
  29. @@ -909,7 +909,7 @@ static NTSTATUS marshal_nfs41_rw(
  30.          print_error("marshal_nfs41_rw: Call to "
  31.              "MmMapLockedPagesSpecifyCache() failed due to "
  32.              "exception 0x%x\n", (int)code);
  33. -        status = STATUS_ACCESS_DENIED;
  34. +        status = STATUS_ACCESS_VIOLATION;
  35.          goto out;
  36.      }
  37.      RtlCopyMemory(tmp, &entry->buf, sizeof(HANDLE));
  38. @@ -1096,7 +1096,7 @@ static NTSTATUS marshal_nfs41_dirquery(
  39.          print_error("marshal_nfs41_dirquery: Call to "
  40.              "MmMapLockedPagesSpecifyCache() failed "
  41.              "due to exception 0x%x\n", (int)code);
  42. -        status = STATUS_ACCESS_DENIED;
  43. +        status = STATUS_ACCESS_VIOLATION;
  44.          goto out;
  45.      }
  46.      RtlCopyMemory(tmp, &entry->u.QueryFile.mdl_buf, sizeof(HANDLE));
  47. @@ -1870,7 +1870,7 @@ static NTSTATUS unmarshal_nfs41_rw(
  48.          code = GetExceptionCode();
  49.          print_error("unmarshal_nfs41_rw: Call to MmUnmapLockedPages() "
  50.              "failed due to exception 0x%0x\n", (int)code);
  51. -        status = STATUS_ACCESS_DENIED;
  52. +        status = STATUS_ACCESS_VIOLATION;
  53.      }
  54.  #endif
  55.      return status;
  56. @@ -1887,7 +1887,7 @@ static NTSTATUS unmarshal_nfs41_open(
  57.              MmUnmapLockedPages(cur->u.Open.EaBuffer, cur->u.Open.EaMdl);
  58.      } __except(EXCEPTION_EXECUTE_HANDLER) {
  59.          print_error("MmUnmapLockedPages thrown exception=0x%0x\n", GetExceptionCode());
  60. -        status = cur->status = STATUS_ACCESS_DENIED;
  61. +        status = cur->status = STATUS_ACCESS_VIOLATION;
  62.          goto out;
  63.      }
  64.  
  65. @@ -1964,7 +1964,7 @@ static NTSTATUS unmarshal_nfs41_dirquery(
  66.          NTSTATUS code;
  67.          code = GetExceptionCode();
  68.          print_error("MmUnmapLockedPages thrown exception=0x%0x\n", code);
  69. -        status = STATUS_ACCESS_DENIED;
  70. +        status = STATUS_ACCESS_VIOLATION;
  71.      }
  72.      if (buf_len > cur->buf_len)
  73.          cur->status = STATUS_BUFFER_TOO_SMALL;
  74. @@ -4917,6 +4917,11 @@ static NTSTATUS nfs41_QueryDirectory(
  75.  #endif
  76.          RxContext->Info.LengthRemaining -= entry->buf_len;
  77.          status = STATUS_SUCCESS;
  78. +    } else if ((entry->status == STATUS_ACCESS_VIOLATION) ||
  79. +        (entry->status == STATUS_INSUFFICIENT_RESOURCES)) {
  80. +        DbgP("nfs41_QueryDirectory: internal error: entry->status=0x%x\n",
  81. +            (int)entry->status);
  82. +        status = STATUS_INSUFFICIENT_RESOURCES;
  83.      } else {
  84.          /* map windows ERRORs to NTSTATUS */
  85.          status = map_querydir_errors(entry->status);
  86. --
  87. 2.45.1
  88.  
  89. From 0be0ca29d0c3032f8ee2cc0cde54332619bf35f7 Mon Sep 17 00:00:00 2001
  90. From: Roland Mainz <roland.mainz@nrubsig.org>
  91. Date: Sat, 10 Aug 2024 16:34:00 +0200
  92. Subject: [PATCH 2/3] sys,tests: Fix "Unhandled/unsupported InfoClass(34)",
  93.  FileNetworkOpenInformation is implemented+test
  94.  
  95. Fix bogus "Unhandled/unsupported InfoClass(34)" debug message,
  96. |FileNetworkOpenInformation| is implemented, and add
  97. a test to winfsinfo.
  98.  
  99. Reported-by: Josh Hurst <joshhurst@gmail.com>
  100. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  101. ---
  102. sys/nfs41_driver.c           |   2 +
  103.  tests/winfsinfo1/winfsinfo.c | 106 +++++++++++++++++++++++++++++++++++
  104.  2 files changed, 108 insertions(+)
  105.  
  106. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  107. index 75a76c3..1554371 100644
  108. --- a/sys/nfs41_driver.c
  109. +++ b/sys/nfs41_driver.c
  110. @@ -6083,6 +6083,8 @@ static NTSTATUS nfs41_QueryFileInformation(
  111.              print_std_info(1, &nfs41_fcb->StandardInfo);
  112.  #endif
  113.              break;
  114. +        case FileNetworkOpenInformation:
  115. +            break;
  116.          default:
  117.              print_error("Unhandled/unsupported InfoClass(%d)\n", (int)InfoClass);
  118.          }
  119. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  120. index 99bcc2f..42591f1 100644
  121. --- a/tests/winfsinfo1/winfsinfo.c
  122. +++ b/tests/winfsinfo1/winfsinfo.c
  123. @@ -35,8 +35,10 @@
  124.  #include <stdio.h>
  125.  #include <windows.h>
  126.  #include <stdlib.h>
  127. +#include <stdint.h>
  128.  #include <stdbool.h>
  129.  
  130. +
  131.  static
  132.  bool getvolumeinfo(const char *progname, const char *filename)
  133.  {
  134. @@ -221,6 +223,106 @@ done:
  135.  }
  136.  
  137.  
  138. +/*
  139. + * Win10 uses |FileNetworkOpenInformation| to get the information
  140. + * for |GetFileExInfoStandard|
  141. + */
  142. +static
  143. +bool get_fileexinfostandard(const char *progname, const char *filename)
  144. +{
  145. +    int res = EXIT_FAILURE;
  146. +    bool ok;
  147. +    WIN32_FILE_ATTRIBUTE_DATA finfo;
  148. +    (void)memset(&finfo, 0, sizeof(finfo));
  149. +
  150. +    ok = GetFileAttributesExA(filename, GetFileExInfoStandard, &finfo);
  151. +
  152. +    if (!ok) {
  153. +        (void)fprintf(stderr, "%s: GetFileAttributesExA(filename='%s') "
  154. +            "error. GetLastError()==%d.\n",
  155. +            progname,
  156. +            filename,
  157. +            (int)GetLastError());
  158. +        res = EXIT_FAILURE;
  159. +        goto done;
  160. +    }
  161. +
  162. +    (void)printf("(\n");
  163. +    (void)printf("\tfilename='%s'\n", filename);
  164. +
  165. +    SYSTEMTIME st;
  166. +
  167. +    /*
  168. +     * Note that SYSTEMTIME is in UTC, so
  169. +     * use $ (TZ=UTC ls -lad "$filename") to compare
  170. +     */
  171. +    (void)FileTimeToSystemTime(&finfo.ftCreationTime, &st);
  172. +    (void)printf("\tftCreationTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
  173. +        st.wYear, st.wMonth, st.wDay, st.wHour,
  174. +        st.wMinute, st.wSecond, st.wMilliseconds);
  175. +
  176. +    (void)FileTimeToSystemTime(&finfo.ftLastAccessTime, &st);
  177. +    (void)printf("\tftLastAccessTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
  178. +        st.wYear, st.wMonth, st.wDay, st.wHour,
  179. +        st.wMinute, st.wSecond, st.wMilliseconds);
  180. +
  181. +    (void)FileTimeToSystemTime(&finfo.ftLastWriteTime, &st);
  182. +    (void)printf("\tftLastWriteTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
  183. +        st.wYear, st.wMonth, st.wDay, st.wHour,
  184. +        st.wMinute, st.wSecond, st.wMilliseconds);
  185. +
  186. +    (void)printf("\tnFileSize=%lld\n",
  187. +        ((long long)finfo.nFileSizeHigh << 32) | finfo.nFileSizeLow);
  188. +
  189. +    DWORD fattr = finfo.dwFileAttributes;
  190. +
  191. +    (void)printf("\ttypeset -a dwFileAttributes=(\n");
  192. +
  193. +#define TESTFEIS(s) \
  194. +    if (fattr & (s)) { \
  195. +        (void)puts("\t\t"#s); \
  196. +        fattr &= ~(s); \
  197. +    }
  198. +    TESTFEIS(FILE_ATTRIBUTE_READONLY);
  199. +    TESTFEIS(FILE_ATTRIBUTE_HIDDEN);
  200. +    TESTFEIS(FILE_ATTRIBUTE_SYSTEM);
  201. +    TESTFEIS(FILE_ATTRIBUTE_DIRECTORY);
  202. +    TESTFEIS(FILE_ATTRIBUTE_ARCHIVE);
  203. +    TESTFEIS(FILE_ATTRIBUTE_DEVICE);
  204. +    TESTFEIS(FILE_ATTRIBUTE_NORMAL);
  205. +    TESTFEIS(FILE_ATTRIBUTE_TEMPORARY);
  206. +    TESTFEIS(FILE_ATTRIBUTE_SPARSE_FILE);
  207. +    TESTFEIS(FILE_ATTRIBUTE_REPARSE_POINT);
  208. +    TESTFEIS(FILE_ATTRIBUTE_COMPRESSED);
  209. +    TESTFEIS(FILE_ATTRIBUTE_OFFLINE);
  210. +    TESTFEIS(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
  211. +    TESTFEIS(FILE_ATTRIBUTE_ENCRYPTED);
  212. +    TESTFEIS(FILE_ATTRIBUTE_INTEGRITY_STREAM);
  213. +    TESTFEIS(FILE_ATTRIBUTE_VIRTUAL);
  214. +    TESTFEIS(FILE_ATTRIBUTE_NO_SCRUB_DATA);
  215. +    TESTFEIS(FILE_ATTRIBUTE_EA);
  216. +    TESTFEIS(FILE_ATTRIBUTE_PINNED);
  217. +    TESTFEIS(FILE_ATTRIBUTE_UNPINNED);
  218. +    TESTFEIS(FILE_ATTRIBUTE_RECALL_ON_OPEN);
  219. +    TESTFEIS(FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS);
  220. +
  221. +    (void)printf("\t)\n");
  222. +
  223. +    /*
  224. +     * print any leftover flags not covered by |TESTFNOI(FILE_*)|
  225. +     * above
  226. +     */
  227. +    if (fattr) {
  228. +        (void)printf("\tfattr=0x%lx\n", (long)fattr);
  229. +    }
  230. +    (void)printf(")\n");
  231. +    res = EXIT_SUCCESS;
  232. +
  233. +done:
  234. +    return res;
  235. +}
  236. +
  237. +
  238.  static
  239.  bool get_file_standard_info(const char *progname, const char *filename)
  240.  {
  241. @@ -343,6 +445,7 @@ void usage(void)
  242.      (void)fprintf(stderr, "winfsinfo <"
  243.          "getvolumeinfo|"
  244.          "filebasicinfo|"
  245. +        "fileexinfostandard|"
  246.          "filestandardinfo|"
  247.          "filenormalizednameinfo"
  248.          "> path\n");
  249. @@ -365,6 +468,9 @@ int main(int ac, char *av[])
  250.      else if (!strcmp(subcmd, "filebasicinfo")) {
  251.          return get_file_basic_info(av[0], av[2]);
  252.      }
  253. +    else if (!strcmp(subcmd, "fileexinfostandard")) {
  254. +        return get_fileexinfostandard(av[0], av[2]);
  255. +    }
  256.      else if (!strcmp(subcmd, "filestandardinfo")) {
  257.          return get_file_standard_info(av[0], av[2]);
  258.      }
  259. --
  260. 2.45.1
  261.  
  262. From 5ca58d817001e2ba97e2190948b1c7e2126b0af6 Mon Sep 17 00:00:00 2001
  263. From: Roland Mainz <roland.mainz@nrubsig.org>
  264. Date: Sat, 10 Aug 2024 16:38:07 +0200
  265. Subject: [PATCH 3/3] cygwin: msnfs41client should force posix=1 for
  266.  nfsclient_mount_homedir
  267.  
  268. msnfs41client should force posix=1 for nfsclient_mount_homedir.
  269.  
  270. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  271. ---
  272. cygwin/devel/msnfs41client.bash | 3 ++-
  273.  1 file changed, 2 insertions(+), 1 deletion(-)
  274.  
  275. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  276. index ce91e0d..7895e9f 100644
  277. --- a/cygwin/devel/msnfs41client.bash
  278. +++ b/cygwin/devel/msnfs41client.bash
  279. @@ -526,7 +526,8 @@ function nfsclient_mount_homedir
  280.         #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
  281.         nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
  282.         mkdir -p '/home/rmainz'
  283. -       mount -o bind,posix=1 '/cygdrive/h' '/home/rmainz'
  284. +       # FIXME: is "notexec" correct in this case =
  285. +       mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
  286.         return $?
  287.  }
  288.  
  289. --
  290. 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