- From 29a8dc6a7b4c4eb7e448459d915d77f8ce5ee33b Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 10 Aug 2024 12:29:56 +0200
- Subject: [PATCH 1/3] sys: |MmMapLockedPagesSpecifyCache()| exceptions should
- return |STATUS_ACCESS_VIOLATION|
- |MmMapLockedPagesSpecifyCache()| exceptions should return
- |STATUS_ACCESS_VIOLATION|, so users can distinguish it
- from normal file access |STATUS_ACCESS_DENIED|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 17 +++++++++++------
- 1 file changed, 11 insertions(+), 6 deletions(-)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index eedfe4e..75a76c3 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -834,7 +834,7 @@ static NTSTATUS marshal_nfs41_open(
- print_error("marshal_nfs41_open: Call to "
- "MmMapLockedPagesSpecifyCache() failed "
- "due to exception 0x%x\n", (int)GetExceptionCode());
- - status = STATUS_ACCESS_DENIED;
- + status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- RtlCopyMemory(tmp, &entry->u.Open.EaBuffer, sizeof(HANDLE));
- @@ -909,7 +909,7 @@ static NTSTATUS marshal_nfs41_rw(
- print_error("marshal_nfs41_rw: Call to "
- "MmMapLockedPagesSpecifyCache() failed due to "
- "exception 0x%x\n", (int)code);
- - status = STATUS_ACCESS_DENIED;
- + status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- RtlCopyMemory(tmp, &entry->buf, sizeof(HANDLE));
- @@ -1096,7 +1096,7 @@ static NTSTATUS marshal_nfs41_dirquery(
- print_error("marshal_nfs41_dirquery: Call to "
- "MmMapLockedPagesSpecifyCache() failed "
- "due to exception 0x%x\n", (int)code);
- - status = STATUS_ACCESS_DENIED;
- + status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- RtlCopyMemory(tmp, &entry->u.QueryFile.mdl_buf, sizeof(HANDLE));
- @@ -1870,7 +1870,7 @@ static NTSTATUS unmarshal_nfs41_rw(
- code = GetExceptionCode();
- print_error("unmarshal_nfs41_rw: Call to MmUnmapLockedPages() "
- "failed due to exception 0x%0x\n", (int)code);
- - status = STATUS_ACCESS_DENIED;
- + status = STATUS_ACCESS_VIOLATION;
- }
- #endif
- return status;
- @@ -1887,7 +1887,7 @@ static NTSTATUS unmarshal_nfs41_open(
- MmUnmapLockedPages(cur->u.Open.EaBuffer, cur->u.Open.EaMdl);
- } __except(EXCEPTION_EXECUTE_HANDLER) {
- print_error("MmUnmapLockedPages thrown exception=0x%0x\n", GetExceptionCode());
- - status = cur->status = STATUS_ACCESS_DENIED;
- + status = cur->status = STATUS_ACCESS_VIOLATION;
- goto out;
- }
- @@ -1964,7 +1964,7 @@ static NTSTATUS unmarshal_nfs41_dirquery(
- NTSTATUS code;
- code = GetExceptionCode();
- print_error("MmUnmapLockedPages thrown exception=0x%0x\n", code);
- - status = STATUS_ACCESS_DENIED;
- + status = STATUS_ACCESS_VIOLATION;
- }
- if (buf_len > cur->buf_len)
- cur->status = STATUS_BUFFER_TOO_SMALL;
- @@ -4917,6 +4917,11 @@ static NTSTATUS nfs41_QueryDirectory(
- #endif
- RxContext->Info.LengthRemaining -= entry->buf_len;
- status = STATUS_SUCCESS;
- + } else if ((entry->status == STATUS_ACCESS_VIOLATION) ||
- + (entry->status == STATUS_INSUFFICIENT_RESOURCES)) {
- + DbgP("nfs41_QueryDirectory: internal error: entry->status=0x%x\n",
- + (int)entry->status);
- + status = STATUS_INSUFFICIENT_RESOURCES;
- } else {
- /* map windows ERRORs to NTSTATUS */
- status = map_querydir_errors(entry->status);
- --
- 2.45.1
- From 0be0ca29d0c3032f8ee2cc0cde54332619bf35f7 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 10 Aug 2024 16:34:00 +0200
- Subject: [PATCH 2/3] sys,tests: Fix "Unhandled/unsupported InfoClass(34)",
- FileNetworkOpenInformation is implemented+test
- Fix bogus "Unhandled/unsupported InfoClass(34)" debug message,
- |FileNetworkOpenInformation| is implemented, and add
- a test to winfsinfo.
- Reported-by: Josh Hurst <joshhurst@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 2 +
- tests/winfsinfo1/winfsinfo.c | 106 +++++++++++++++++++++++++++++++++++
- 2 files changed, 108 insertions(+)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 75a76c3..1554371 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -6083,6 +6083,8 @@ static NTSTATUS nfs41_QueryFileInformation(
- print_std_info(1, &nfs41_fcb->StandardInfo);
- #endif
- break;
- + case FileNetworkOpenInformation:
- + break;
- default:
- print_error("Unhandled/unsupported InfoClass(%d)\n", (int)InfoClass);
- }
- diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
- index 99bcc2f..42591f1 100644
- --- a/tests/winfsinfo1/winfsinfo.c
- +++ b/tests/winfsinfo1/winfsinfo.c
- @@ -35,8 +35,10 @@
- #include <stdio.h>
- #include <windows.h>
- #include <stdlib.h>
- +#include <stdint.h>
- #include <stdbool.h>
- +
- static
- bool getvolumeinfo(const char *progname, const char *filename)
- {
- @@ -221,6 +223,106 @@ done:
- }
- +/*
- + * Win10 uses |FileNetworkOpenInformation| to get the information
- + * for |GetFileExInfoStandard|
- + */
- +static
- +bool get_fileexinfostandard(const char *progname, const char *filename)
- +{
- + int res = EXIT_FAILURE;
- + bool ok;
- + WIN32_FILE_ATTRIBUTE_DATA finfo;
- + (void)memset(&finfo, 0, sizeof(finfo));
- +
- + ok = GetFileAttributesExA(filename, GetFileExInfoStandard, &finfo);
- +
- + if (!ok) {
- + (void)fprintf(stderr, "%s: GetFileAttributesExA(filename='%s') "
- + "error. GetLastError()==%d.\n",
- + progname,
- + filename,
- + (int)GetLastError());
- + res = EXIT_FAILURE;
- + goto done;
- + }
- +
- + (void)printf("(\n");
- + (void)printf("\tfilename='%s'\n", filename);
- +
- + SYSTEMTIME st;
- +
- + /*
- + * Note that SYSTEMTIME is in UTC, so
- + * use $ (TZ=UTC ls -lad "$filename") to compare
- + */
- + (void)FileTimeToSystemTime(&finfo.ftCreationTime, &st);
- + (void)printf("\tftCreationTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
- + st.wYear, st.wMonth, st.wDay, st.wHour,
- + st.wMinute, st.wSecond, st.wMilliseconds);
- +
- + (void)FileTimeToSystemTime(&finfo.ftLastAccessTime, &st);
- + (void)printf("\tftLastAccessTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
- + st.wYear, st.wMonth, st.wDay, st.wHour,
- + st.wMinute, st.wSecond, st.wMilliseconds);
- +
- + (void)FileTimeToSystemTime(&finfo.ftLastWriteTime, &st);
- + (void)printf("\tftLastWriteTime='%04d-%02d-%02d %02d:%02d:%02d.%d'\n",
- + st.wYear, st.wMonth, st.wDay, st.wHour,
- + st.wMinute, st.wSecond, st.wMilliseconds);
- +
- + (void)printf("\tnFileSize=%lld\n",
- + ((long long)finfo.nFileSizeHigh << 32) | finfo.nFileSizeLow);
- +
- + DWORD fattr = finfo.dwFileAttributes;
- +
- + (void)printf("\ttypeset -a dwFileAttributes=(\n");
- +
- +#define TESTFEIS(s) \
- + if (fattr & (s)) { \
- + (void)puts("\t\t"#s); \
- + fattr &= ~(s); \
- + }
- + TESTFEIS(FILE_ATTRIBUTE_READONLY);
- + TESTFEIS(FILE_ATTRIBUTE_HIDDEN);
- + TESTFEIS(FILE_ATTRIBUTE_SYSTEM);
- + TESTFEIS(FILE_ATTRIBUTE_DIRECTORY);
- + TESTFEIS(FILE_ATTRIBUTE_ARCHIVE);
- + TESTFEIS(FILE_ATTRIBUTE_DEVICE);
- + TESTFEIS(FILE_ATTRIBUTE_NORMAL);
- + TESTFEIS(FILE_ATTRIBUTE_TEMPORARY);
- + TESTFEIS(FILE_ATTRIBUTE_SPARSE_FILE);
- + TESTFEIS(FILE_ATTRIBUTE_REPARSE_POINT);
- + TESTFEIS(FILE_ATTRIBUTE_COMPRESSED);
- + TESTFEIS(FILE_ATTRIBUTE_OFFLINE);
- + TESTFEIS(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
- + TESTFEIS(FILE_ATTRIBUTE_ENCRYPTED);
- + TESTFEIS(FILE_ATTRIBUTE_INTEGRITY_STREAM);
- + TESTFEIS(FILE_ATTRIBUTE_VIRTUAL);
- + TESTFEIS(FILE_ATTRIBUTE_NO_SCRUB_DATA);
- + TESTFEIS(FILE_ATTRIBUTE_EA);
- + TESTFEIS(FILE_ATTRIBUTE_PINNED);
- + TESTFEIS(FILE_ATTRIBUTE_UNPINNED);
- + TESTFEIS(FILE_ATTRIBUTE_RECALL_ON_OPEN);
- + TESTFEIS(FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS);
- +
- + (void)printf("\t)\n");
- +
- + /*
- + * print any leftover flags not covered by |TESTFNOI(FILE_*)|
- + * above
- + */
- + if (fattr) {
- + (void)printf("\tfattr=0x%lx\n", (long)fattr);
- + }
- + (void)printf(")\n");
- + res = EXIT_SUCCESS;
- +
- +done:
- + return res;
- +}
- +
- +
- static
- bool get_file_standard_info(const char *progname, const char *filename)
- {
- @@ -343,6 +445,7 @@ void usage(void)
- (void)fprintf(stderr, "winfsinfo <"
- "getvolumeinfo|"
- "filebasicinfo|"
- + "fileexinfostandard|"
- "filestandardinfo|"
- "filenormalizednameinfo"
- "> path\n");
- @@ -365,6 +468,9 @@ int main(int ac, char *av[])
- else if (!strcmp(subcmd, "filebasicinfo")) {
- return get_file_basic_info(av[0], av[2]);
- }
- + else if (!strcmp(subcmd, "fileexinfostandard")) {
- + return get_fileexinfostandard(av[0], av[2]);
- + }
- else if (!strcmp(subcmd, "filestandardinfo")) {
- return get_file_standard_info(av[0], av[2]);
- }
- --
- 2.45.1
- From 5ca58d817001e2ba97e2190948b1c7e2126b0af6 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 10 Aug 2024 16:38:07 +0200
- Subject: [PATCH 3/3] cygwin: msnfs41client should force posix=1 for
- nfsclient_mount_homedir
- msnfs41client should force posix=1 for nfsclient_mount_homedir.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index ce91e0d..7895e9f 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -526,7 +526,8 @@ function nfsclient_mount_homedir
- #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
- nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
- mkdir -p '/home/rmainz'
- - mount -o bind,posix=1 '/cygdrive/h' '/home/rmainz'
- + # FIXME: is "notexec" correct in this case =
- + mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
- return $?
- }
- --
- 2.45.1
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
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.