From d8c1599a499801ba7bbfe2d26397df0974a8848a Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 29 Sep 2021 09:12:17 +1000 Subject: [PATCH] Rebase against bcdb28a563d43f2aebe28f457497bb36f59a50ea. --- ...f-a-WRITECOPY-page-has-been-modified.patch | 27 +++++++------------ ...unmodified-WRITECOPY-pages-as-shared.patch | 12 ++++----- patches/patchinstall.sh | 2 +- staging/upstream-commit | 2 +- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch index 47baccd9..764c143a 100644 --- a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch +++ b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch @@ -1,4 +1,4 @@ -From d528d994e0bd5c51c24c30c674bcce118d09bf4a Mon Sep 17 00:00:00 2001 +From dd7071e971c22e8100510f51763b0efa4e03eb33 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:14 -0500 Subject: [PATCH] ntdll: Track if a WRITECOPY page has been modified. @@ -8,11 +8,11 @@ read-write page. Signed-off-by: Andrew Wesie --- - dlls/ntdll/unix/virtual.c | 26 ++++++++++++++++++++------ - 1 file changed, 20 insertions(+), 6 deletions(-) + dlls/ntdll/unix/virtual.c | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index b75df0a05c0..f31613911fd 100644 +index 312448de4a0..37264c91689 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -141,6 +141,7 @@ struct file_view @@ -23,7 +23,7 @@ index b75df0a05c0..f31613911fd 100644 /* per-mapping protection flags */ #define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */ #define VPROT_NATIVE 0x0400 -@@ -1029,7 +1030,7 @@ static int get_unix_prot( BYTE vprot ) +@@ -1136,7 +1137,7 @@ static int get_unix_prot( BYTE vprot ) #if defined(__i386__) if (vprot & VPROT_WRITECOPY) { @@ -32,7 +32,7 @@ index b75df0a05c0..f31613911fd 100644 prot = (prot & ~PROT_WRITE) | PROT_READ; else prot |= PROT_WRITE | PROT_READ; -@@ -1466,7 +1467,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz +@@ -1573,7 +1574,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz */ static DWORD get_win32_prot( BYTE vprot, unsigned int map_prot ) { @@ -45,7 +45,7 @@ index b75df0a05c0..f31613911fd 100644 if (vprot & VPROT_GUARD) ret |= PAGE_GUARD; if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; return ret; -@@ -1577,12 +1582,21 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr +@@ -1684,12 +1689,21 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr if (view->protect & VPROT_WRITEWATCH) { /* each page may need different protections depending on write watch flag */ @@ -69,7 +69,7 @@ index b75df0a05c0..f31613911fd 100644 return TRUE; } -@@ -3321,7 +3335,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) +@@ -3449,7 +3463,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) } if (vprot & VPROT_WRITECOPY) { @@ -78,15 +78,6 @@ index b75df0a05c0..f31613911fd 100644 mprotect_range( page, page_size, 0, 0 ); } /* ignore fault if page is writable now */ -@@ -4238,7 +4252,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr, - else if (view->protect & (SEC_FILE | SEC_RESERVE | SEC_COMMIT)) info->Type = MEM_MAPPED; - else info->Type = MEM_PRIVATE; - for (ptr = base; ptr < base + range_size; ptr += page_size) -- if ((get_page_vprot( ptr ) ^ vprot) & ~VPROT_WRITEWATCH) break; -+ if ((get_page_vprot( ptr ) ^ vprot) & ~(VPROT_WRITEWATCH|VPROT_WRITTEN)) break; - info->RegionSize = ptr - base; - } - server_leave_uninterrupted_section( &virtual_mutex, &sigset ); -- -2.30.2 +2.33.0 diff --git a/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch b/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch index be42d7d3..c4775be7 100644 --- a/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch +++ b/patches/ntdll-WRITECOPY/0007-ntdll-Report-unmodified-WRITECOPY-pages-as-shared.patch @@ -1,4 +1,4 @@ -From 961363c939e566a74b9343ad2e328b1f6fce7361 Mon Sep 17 00:00:00 2001 +From 94c657aca5daa972b3c8ce07642471c2b47818ef Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:17 -0500 Subject: [PATCH] ntdll: Report unmodified WRITECOPY pages as shared. @@ -13,10 +13,10 @@ Signed-off-by: Andrew Wesie 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 16cfa8bda2d7..8b3f93b70d41 100644 +index 0f0fcc4517b..3c74585d160 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -2174,6 +2174,8 @@ static NTSTATUS map_image_into_view( struct file_view *view, int fd, void *orig_ +@@ -2509,6 +2509,8 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena ptr + sec->VirtualAddress + file_size, ptr + sec->VirtualAddress + end ); memset( ptr + sec->VirtualAddress + file_size, 0, end - file_size ); @@ -25,8 +25,8 @@ index 16cfa8bda2d7..8b3f93b70d41 100644 } } -@@ -3937,7 +3939,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, - (vprot & VPROT_COMMITTED)) +@@ -4431,7 +4433,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr, + (vprot & VPROT_COMMITTED)) { p->VirtualAttributes.Valid = !(vprot & VPROT_GUARD) && (vprot & 0x0f) && (pagemap >> 63); - p->VirtualAttributes.Shared = !is_view_valloc( view ) && ((pagemap >> 61) & 1); @@ -35,5 +35,5 @@ index 16cfa8bda2d7..8b3f93b70d41 100644 p->VirtualAttributes.ShareCount = 1; /* FIXME */ if (p->VirtualAttributes.Valid) -- -2.20.1 +2.33.0 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index aad6c2ef..19da8c07 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -51,7 +51,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "de7adacedbdd78fd1ed8ee0986a78670e11a60bc" + echo "bcdb28a563d43f2aebe28f457497bb36f59a50ea" } # Show version information diff --git a/staging/upstream-commit b/staging/upstream-commit index 9a7826f0..13d397ba 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -de7adacedbdd78fd1ed8ee0986a78670e11a60bc +bcdb28a563d43f2aebe28f457497bb36f59a50ea