ntdll-Syscall_Wrappers: Run directory initialization early during process startup instead of wrapping syscalls.

This commit is contained in:
Sebastian Lackner 2015-10-17 12:49:06 +02:00
parent 6971149e11
commit 091bcbce3c
5 changed files with 141 additions and 98 deletions

View File

@ -1,4 +1,4 @@
From c2f89b20617d6d3e89c518c7ccb10f493d75efa4 Mon Sep 17 00:00:00 2001
From 1b29dfe82eab39b3fc91bfadb82c2822abcef859 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 11:26:48 -0600
Subject: ntdll: Perform the Unix-style hidden file check within the unified
@ -11,10 +11,10 @@ Subject: ntdll: Perform the Unix-style hidden file check within the unified
3 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 9b10385..a85c5e1 100644
index 94b6d77..9bb0e13 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1199,17 +1199,17 @@ static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **contex
@@ -1214,15 +1214,15 @@ void DIR_init_options(void)
*
* Check if the specified file should be hidden based on its name and the show dot files option.
*/
@ -24,8 +24,6 @@ index 9b10385..a85c5e1 100644
- WCHAR *p, *end;
+ char *p, *end;
RtlRunOnceExecuteOnce( &init_once, init_options, NULL, NULL );
if (show_dot_files) return FALSE;
- end = p = name->Buffer + name->Length/sizeof(WCHAR);
@ -37,7 +35,7 @@ index 9b10385..a85c5e1 100644
if (p == end || *p != '.') return FALSE;
/* make sure it isn't '.' or '..' */
if (p + 1 == end) return FALSE;
@@ -1424,9 +1424,6 @@ static union file_directory_info *append_entry( void *info_ptr, IO_STATUS_BLOCK
@@ -1437,9 +1437,6 @@ static union file_directory_info *append_entry( void *info_ptr, IO_STATUS_BLOCK
TRACE( "ignoring file %s\n", long_name );
return NULL;
}
@ -48,10 +46,10 @@ index 9b10385..a85c5e1 100644
if (io->Information + total_len > max_length)
{
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index b4187d4..45caa2e 100644
index 0b4754e..cfd967e 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -199,6 +199,10 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
@@ -213,6 +213,10 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
if (S_ISDIR( st->st_mode )) *attr |= FILE_ATTRIBUTE_REPARSE_POINT;
}
*attr |= get_file_attributes( st );
@ -62,7 +60,7 @@ index b4187d4..45caa2e 100644
len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
if (len == -1) return ret;
*attr |= get_file_xattr( hexattr, len );
@@ -2567,8 +2571,6 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
@@ -2997,8 +3001,6 @@ NTSTATUS WINAPI SYSCALL(NtQueryFullAttributesFile)( const OBJECT_ATTRIBUTES *att
info->AllocationSize = std.AllocationSize;
info->EndOfFile = std.EndOfFile;
info->FileAttributes = basic.FileAttributes;
@ -71,7 +69,7 @@ index b4187d4..45caa2e 100644
}
RtlFreeAnsiString( &unix_name );
}
@@ -2596,11 +2598,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
@@ -3027,11 +3029,7 @@ NTSTATUS WINAPI SYSCALL(NtQueryAttributesFile)( const OBJECT_ATTRIBUTES *attr, F
else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
status = STATUS_INVALID_INFO_CLASS;
else
@ -84,12 +82,12 @@ index b4187d4..45caa2e 100644
}
else WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), status );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index b7ea6dc..1ab120c 100644
index 5ba1308..e46ba22 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -153,7 +153,7 @@ extern NTSTATUS fill_file_info( const struct stat *st, ULONG attr, void *ptr,
FILE_INFORMATION_CLASS class ) DECLSPEC_HIDDEN;
@@ -155,7 +155,7 @@ extern NTSTATUS fill_file_info( const struct stat *st, ULONG attr, void *ptr,
extern NTSTATUS server_get_unix_name( HANDLE handle, ANSI_STRING *unix_name ) DECLSPEC_HIDDEN;
extern void DIR_init_options(void) DECLSPEC_HIDDEN;
extern void DIR_init_windows_dir( const WCHAR *windir, const WCHAR *sysdir ) DECLSPEC_HIDDEN;
-extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name ) DECLSPEC_HIDDEN;
+extern BOOL DIR_is_hidden_file( const char *name ) DECLSPEC_HIDDEN;
@ -97,5 +95,5 @@ index b7ea6dc..1ab120c 100644
extern NTSTATUS DIR_get_unix_cwd( char **cwd ) DECLSPEC_HIDDEN;
extern unsigned int DIR_get_drives_info( struct drive_info info[MAX_DOS_DRIVES] ) DECLSPEC_HIDDEN;
--
1.9.1
2.6.1

View File

@ -1,2 +1,3 @@
Fixes: [9158] Support for DOS hidden/system file attributes
Depends: ntdll-Syscall_Wrappers
Category: stable

View File

@ -1,57 +0,0 @@
From dd80beb72d31aa4cb1713e669e0030cfbc246a71 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 16 Oct 2015 05:54:08 +0200
Subject: ntdll: Call implementation instead of thunk wrappers in init_options.
---
dlls/ntdll/directory.c | 6 +++---
dlls/ntdll/ntdll_misc.h | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 770cd3f..5c595c8 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1188,15 +1188,15 @@ static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **contex
RtlInitUnicodeString( &nameW, WineW );
/* @@ Wine registry key: HKCU\Software\Wine */
- if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
+ if (!SYSCALL(NtOpenKey)( &hkey, KEY_ALL_ACCESS, &attr ))
{
RtlInitUnicodeString( &nameW, ShowDotFilesW );
- if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
+ if (!SYSCALL(NtQueryValueKey)( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
show_dot_files = IS_OPTION_TRUE( str[0] );
}
- NtClose( hkey );
+ SYSCALL(NtClose)( hkey );
}
NtClose( root );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 11099c5..cf2b33b 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -273,13 +273,16 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN;
extern typeof( name ) __syscall_ ## name
DECLARE_SYSCALL_ENTRYPOINT( NtAllocateVirtualMemory );
+DECLARE_SYSCALL_ENTRYPOINT( NtClose );
DECLARE_SYSCALL_ENTRYPOINT( NtFlushVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtFreeVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtLockVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtMapViewOfSection );
+DECLARE_SYSCALL_ENTRYPOINT( NtOpenKey );
DECLARE_SYSCALL_ENTRYPOINT( NtOpenProcessTokenEx );
DECLARE_SYSCALL_ENTRYPOINT( NtOpenThreadTokenEx );
DECLARE_SYSCALL_ENTRYPOINT( NtProtectVirtualMemory );
+DECLARE_SYSCALL_ENTRYPOINT( NtQueryValueKey );
DECLARE_SYSCALL_ENTRYPOINT( NtQueryVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtUnlockVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtUnmapViewOfSection );
--
2.6.1

View File

@ -0,0 +1,91 @@
From 3a40ae6b1e3cd67ea606a7af6938788fe470773e Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 16 Oct 2015 05:54:08 +0200
Subject: ntdll: Run directory initialization function early during the process
startup.
---
dlls/ntdll/directory.c | 10 ++--------
dlls/ntdll/loader.c | 1 +
dlls/ntdll/ntdll_misc.h | 1 +
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 770cd3f..94b6d77 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -176,7 +176,6 @@ union file_directory_info
};
static BOOL show_dot_files;
-static RTL_RUN_ONCE init_once = RTL_RUN_ONCE_INIT;
/* at some point we may want to allow Winelib apps to set this */
static const BOOL is_case_sensitive = FALSE;
@@ -1164,11 +1163,11 @@ static BOOLEAN get_dir_case_sensitivity( const char *dir )
/***********************************************************************
- * init_options
+ * DIR_init_options
*
* Initialize the show_dot_files options.
*/
-static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **context )
+void DIR_init_options(void)
{
static const WCHAR WineW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
@@ -1207,7 +1206,6 @@ static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **contex
#ifdef linux
ignore_file( "/sys" );
#endif
- return TRUE;
}
@@ -1220,8 +1218,6 @@ BOOL DIR_is_hidden_file( const UNICODE_STRING *name )
{
WCHAR *p, *end;
- RtlRunOnceExecuteOnce( &init_once, init_options, NULL, NULL );
-
if (show_dot_files) return FALSE;
end = p = name->Buffer + name->Length/sizeof(WCHAR);
@@ -2278,8 +2274,6 @@ NTSTATUS WINAPI SYSCALL(NtQueryDirectoryFile)( HANDLE handle, HANDLE event,
io->Information = 0;
- RtlRunOnceExecuteOnce( &init_once, init_options, NULL, NULL );
-
RtlEnterCriticalSection( &dir_section );
cwd = open( ".", O_RDONLY );
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index ecbc885..04cbb63 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3283,6 +3283,7 @@ void __wine_process_init(void)
umask( FILE_umask );
load_global_options();
+ DIR_init_options();
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 11099c5..5ba1308 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -153,6 +153,7 @@ extern int get_file_info( const char *path, struct stat *st, ULONG *attr ) DECLS
extern NTSTATUS fill_file_info( const struct stat *st, ULONG attr, void *ptr,
FILE_INFORMATION_CLASS class ) DECLSPEC_HIDDEN;
extern NTSTATUS server_get_unix_name( HANDLE handle, ANSI_STRING *unix_name ) DECLSPEC_HIDDEN;
+extern void DIR_init_options(void) DECLSPEC_HIDDEN;
extern void DIR_init_windows_dir( const WCHAR *windir, const WCHAR *sysdir ) DECLSPEC_HIDDEN;
extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name ) DECLSPEC_HIDDEN;
extern NTSTATUS DIR_unmount_device( HANDLE handle ) DECLSPEC_HIDDEN;
--
2.6.1

View File

@ -1898,6 +1898,13 @@ if test "$enable_ntdll_Dealloc_Thread_Stack" -eq 1; then
enable_ntdll_Virtual_Memory_Stack=1
fi
if test "$enable_ntdll_DOS_Attributes" -eq 1; then
if test "$enable_ntdll_Syscall_Wrappers" -gt 1; then
abort "Patchset ntdll-Syscall_Wrappers disabled, but ntdll-DOS_Attributes depends on that."
fi
enable_ntdll_Syscall_Wrappers=1
fi
if test "$enable_ntdll_CLI_Images" -eq 1; then
if test "$enable_mscoree_CorValidateImage" -gt 1; then
abort "Patchset mscoree-CorValidateImage disabled, but ntdll-CLI_Images depends on that."
@ -3861,8 +3868,36 @@ if test "$enable_ntdll_CLI_Images" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-Syscall_Wrappers
# |
# | This patchset fixes the following Wine bugs:
# | * [#39403] Use wrapper functions for syscalls to appease Chromium sandbox (32-bit)
# |
# | Modified files:
# | * dlls/ntdll/atom.c, dlls/ntdll/directory.c, dlls/ntdll/env.c, dlls/ntdll/error.c, dlls/ntdll/file.c, dlls/ntdll/loader.c,
# | dlls/ntdll/nt.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/om.c, dlls/ntdll/process.c, dlls/ntdll/reg.c,
# | dlls/ntdll/resource.c, dlls/ntdll/sec.c, dlls/ntdll/server.c, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c,
# | dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/sync.c,
# | dlls/ntdll/thread.c, dlls/ntdll/time.c, dlls/ntdll/virtual.c
# |
if test "$enable_ntdll_Syscall_Wrappers" -eq 1; then
patch_apply ntdll-Syscall_Wrappers/0001-ntdll-Use-wrapper-functions-for-syscalls.patch
patch_apply ntdll-Syscall_Wrappers/0002-ntdll-APCs-should-call-the-implementation-instead-of.patch
patch_apply ntdll-Syscall_Wrappers/0003-ntdll-Syscalls-should-not-call-Nt-Ex-thunk-wrappers.patch
patch_apply ntdll-Syscall_Wrappers/0004-ntdll-Run-directory-initialization-function-early-du.patch
(
echo '+ { "Sebastian Lackner", "ntdll: Use wrapper functions for syscalls.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: APCs should call the implementation instead of the syscall thunk.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Syscalls should not call Nt*Ex thunk wrappers.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Run directory initialization function early during the process startup.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-DOS_Attributes
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-Syscall_Wrappers
# |
# | This patchset fixes the following Wine bugs:
# | * [#9158] Support for DOS hidden/system file attributes
# |
@ -4071,31 +4106,6 @@ if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-Syscall_Wrappers
# |
# | This patchset fixes the following Wine bugs:
# | * [#39403] Use wrapper functions for syscalls to appease Chromium sandbox (32-bit)
# |
# | Modified files:
# | * dlls/ntdll/atom.c, dlls/ntdll/directory.c, dlls/ntdll/env.c, dlls/ntdll/error.c, dlls/ntdll/file.c, dlls/ntdll/loader.c,
# | dlls/ntdll/nt.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/om.c, dlls/ntdll/process.c, dlls/ntdll/reg.c,
# | dlls/ntdll/resource.c, dlls/ntdll/sec.c, dlls/ntdll/server.c, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c,
# | dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/sync.c,
# | dlls/ntdll/thread.c, dlls/ntdll/time.c, dlls/ntdll/virtual.c
# |
if test "$enable_ntdll_Syscall_Wrappers" -eq 1; then
patch_apply ntdll-Syscall_Wrappers/0001-ntdll-Use-wrapper-functions-for-syscalls.patch
patch_apply ntdll-Syscall_Wrappers/0002-ntdll-APCs-should-call-the-implementation-instead-of.patch
patch_apply ntdll-Syscall_Wrappers/0003-ntdll-Syscalls-should-not-call-Nt-Ex-thunk-wrappers.patch
patch_apply ntdll-Syscall_Wrappers/0004-ntdll-Call-implementation-instead-of-thunk-wrappers-.patch
(
echo '+ { "Sebastian Lackner", "ntdll: Use wrapper functions for syscalls.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: APCs should call the implementation instead of the syscall thunk.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Syscalls should not call Nt*Ex thunk wrappers.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Call implementation instead of thunk wrappers in init_options.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-NtQueryEaFile
# |
# | This patchset has the following (direct or indirect) dependencies:
@ -4699,7 +4709,7 @@ fi
# Patchset server-Stored_ACLs
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DOS_Attributes, server-File_Permissions
# | * ntdll-Syscall_Wrappers, ntdll-DOS_Attributes, server-File_Permissions
# |
# | This patchset fixes the following Wine bugs:
# | * [#33576] Support for stored file ACLs
@ -4730,7 +4740,7 @@ fi
# Patchset server-Inherited_ACLs
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DOS_Attributes, server-File_Permissions, server-Stored_ACLs
# | * ntdll-Syscall_Wrappers, ntdll-DOS_Attributes, server-File_Permissions, server-Stored_ACLs
# |
# | Modified files:
# | * dlls/advapi32/tests/security.c, server/file.c