Rebase against 7f0fac46d718e0961314d0c50342dcf336b9803d.

This commit is contained in:
Elizabeth Figura
2025-06-23 16:47:48 -05:00
parent 7db26cf727
commit 5054f7359b
3 changed files with 45 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
From c8fe58f588703421d2e85eb6376d93e3299f0880 Mon Sep 17 00:00:00 2001
From 32aeea846670432cf1e8d90defe6ca486b710559 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 20:56:49 -0700
Subject: [PATCH] ntdll: Add support for creating reparse points.
@@ -7,16 +7,16 @@ Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
---
configure.ac | 2 +
dlls/ntdll/Makefile.in | 2 +-
dlls/ntdll/tests/file.c | 159 ++++++++++++++++++---
dlls/ntdll/tests/file.c | 157 ++++++++++++++++++---
dlls/ntdll/unix/file.c | 302 ++++++++++++++++++++++++++++++++++++++++
include/ddk/ntifs.h | 5 +
5 files changed, 451 insertions(+), 19 deletions(-)
5 files changed, 450 insertions(+), 18 deletions(-)
diff --git a/configure.ac b/configure.ac
index a171e143136..abd91b6b51f 100644
index 6d093b52526..c9e433f4e6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2084,6 +2084,8 @@ AC_CHECK_FUNCS(\
@@ -2111,6 +2111,8 @@ AC_CHECK_FUNCS(\
prctl \
sched_getcpu \
sched_yield \
@@ -39,7 +39,7 @@ index f7558bb5d86..aad14d17e61 100644
EXTRADLLFLAGS = -nodefaultlibs
i386_EXTRADLLFLAGS = -Wl,--image-base,0x7bc00000
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index cc0afdbdb64..00f90552e84 100644
index a2ccf3f5332..121ebe5d62a 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -38,6 +38,7 @@
@@ -50,7 +50,7 @@ index cc0afdbdb64..00f90552e84 100644
#ifndef IO_COMPLETION_ALL_ACCESS
#define IO_COMPLETION_ALL_ACCESS 0x001F0003
@@ -6028,32 +6029,154 @@ static void test_mailslot_name(void)
@@ -5970,32 +5971,154 @@ static void test_mailslot_name(void)
CloseHandle( device );
}
@@ -127,15 +127,17 @@ index cc0afdbdb64..00f90552e84 100644
+ RemoveDirectoryW(path);
+ return;
+ }
+
- pRtlInitUnicodeString( &nameW, L"\\??\\C:\\" );
- InitializeObjectAttributes( &attr, &nameW, 0, NULL, NULL );
+ /* Create the folder to be replaced by a junction point */
+ lstrcpyW(reparse_path, path);
+ lstrcatW(reparse_path, reparseW);
+ bret = CreateDirectoryW(reparse_path, NULL);
+ ok(bret, "Failed to create junction point directory.\n");
- pRtlInitUnicodeString( &nameW, L"\\??\\C:\\" );
- InitializeObjectAttributes( &attr, &nameW, 0, NULL, NULL );
- status = pNtOpenFile( &handle, READ_CONTROL, &attr, &io, 0, 0 );
- ok( !status, "open %s failed %#lx\n", wine_dbgstr_w(nameW.Buffer), status );
+ /* Create a destination folder for the junction point to target */
+ lstrcpyW(target_path, path);
+ for (int i=0; i<1; i++)
@@ -148,8 +150,8 @@ index cc0afdbdb64..00f90552e84 100644
+ ok(bret, "Failed to create junction point target directory.\n");
+ pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
- status = pNtOpenFile( &handle, READ_CONTROL, &attr, &io, 0, 0 );
- ok( !status, "open %s failed %#lx\n", wine_dbgstr_w(nameW.Buffer), status );
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, NULL, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
+ /* construct a too long pathname (resulting reparse buffer over 16 kiB limit) */
+ long_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32767);
+ lstrcpyW(long_path, nameW.Buffer);
@@ -159,7 +161,9 @@ index cc0afdbdb64..00f90552e84 100644
+ lstrcatW(long_path, path);
+ }
+ lstrcatW(long_path, targetW);
+
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
+ /* Create the junction point */
+ handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0);
@@ -174,8 +178,9 @@ index cc0afdbdb64..00f90552e84 100644
+ HeapFree(GetProcessHeap(), 0, buffer);
+ CloseHandle(handle);
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, NULL, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
- /* a volume cannot be a reparse point by definition */
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 1 );
- ok( status == STATUS_NOT_A_REPARSE_POINT, "expected %#lx, got %#lx\n", STATUS_NOT_A_REPARSE_POINT, status );
+ /* construct a long pathname to demonstrate correct behavior with very large reparse points */
+ pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
+ lstrcpyW(long_path, nameW.Buffer);
@@ -186,15 +191,11 @@ index cc0afdbdb64..00f90552e84 100644
+ }
+ lstrcatW(long_path, targetW);
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
- CloseHandle( handle );
+ /* use a sane (not obscenely long) target for the rest of testing */
+ pRtlFreeUnicodeString(&nameW);
+ pRtlDosPathNameToNtPathName_U(target_path, &nameW, NULL, NULL);
- /* a volume cannot be a reparse point by definition */
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 1 );
- ok( status == STATUS_NOT_A_REPARSE_POINT, "expected %#lx, got %#lx\n", STATUS_NOT_A_REPARSE_POINT, status );
+
+ /* Create the junction point */
+ handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0);
@@ -207,8 +208,7 @@ index cc0afdbdb64..00f90552e84 100644
+ bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
+ ok(bret, "Failed to create junction point! (0x%lx)\n", GetLastError());
+ CloseHandle(handle);
- CloseHandle( handle );
+
+cleanup:
+ /* Cleanup */
+ pRtlFreeUnicodeString(&nameW);
@@ -222,16 +222,8 @@ index cc0afdbdb64..00f90552e84 100644
}
static void test_set_io_completion_ex(void)
@@ -6193,6 +6316,6 @@ START_TEST(file)
test_ioctl();
test_query_ea();
test_flush_buffers_file();
- test_mailslot_name();
test_reparse_points();
+ test_mailslot_name();
}
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index faef06ae084..a47c3d90df4 100644
index 8d2809ca193..672a1d1fa27 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -36,6 +36,8 @@
@@ -264,7 +256,7 @@ index faef06ae084..a47c3d90df4 100644
#ifdef linux
/* We want the real kernel dirent structure, not the libc one */
@@ -243,6 +252,95 @@ static const BOOL is_case_sensitive = FALSE;
@@ -244,6 +253,95 @@ static const BOOL is_case_sensitive = FALSE;
static pthread_mutex_t dir_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mnt_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -360,7 +352,7 @@ index faef06ae084..a47c3d90df4 100644
/* check if a given Unicode char is OK in a DOS short name */
static inline BOOL is_invalid_dos_char( WCHAR ch )
{
@@ -1641,6 +1739,28 @@ static int parse_samba_dos_attrib_data( char *data, int len )
@@ -1665,6 +1763,28 @@ static int parse_samba_dos_attrib_data( char *data, int len )
}
@@ -389,7 +381,7 @@ index faef06ae084..a47c3d90df4 100644
static BOOL fd_is_mount_point( int fd, const struct stat *st )
{
struct stat parent;
@@ -3441,6 +3561,181 @@ done:
@@ -3528,6 +3648,181 @@ done:
}
@@ -571,7 +563,7 @@ index faef06ae084..a47c3d90df4 100644
/******************************************************************************
* lookup_unix_name
*
@@ -6271,6 +6566,13 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap
@@ -6415,6 +6710,13 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap
break;
}

View File

@@ -1,4 +1,4 @@
From 222ae102097fd34e6ff52813d1c0a165c7165776 Mon Sep 17 00:00:00 2001
From f4a1348aaf4998e1d5c5a8014d38326982ce5f3d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 12 Nov 2018 18:10:32 +0200
Subject: [PATCH] server: Do not signal violently terminated threads until they
@@ -22,15 +22,15 @@ no guarantee currently that the terminated thread really stopped executing.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
---
server/thread.c | 32 +++++++++++++++++++++++++++++---
server/thread.c | 31 +++++++++++++++++++++++++++++--
server/thread.h | 1 +
2 files changed, 30 insertions(+), 3 deletions(-)
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/server/thread.c b/server/thread.c
index f7e5e5fabe8..506adfc0a6f 100644
index 05ec6a4ec00..b3b971548bc 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -246,6 +246,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -422,6 +422,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->token = NULL;
thread->desc = NULL;
thread->desc_len = 0;
@@ -38,24 +38,15 @@ index f7e5e5fabe8..506adfc0a6f 100644
thread->creation_time = current_time;
thread->exit_time = 0;
@@ -450,6 +451,7 @@ static void destroy_thread( struct object *obj )
@@ -642,6 +643,7 @@ static void destroy_thread( struct object *obj )
list_remove( &thread->entry );
cleanup_thread( thread );
release_object( thread->process );
+ if (thread->exit_poll) remove_timeout_user( thread->exit_poll );
if (thread->id) free_ptid( thread->id );
if (thread->token) release_object( thread->token );
}
@@ -467,7 +469,7 @@ static void dump_thread( struct object *obj, int verbose )
static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
{
struct thread *mythread = (struct thread *)obj;
- return (mythread->state == TERMINATED);
+ return mythread->state == TERMINATED && !mythread->exit_poll;
}
static unsigned int thread_map_access( struct object *obj, unsigned int access )
@@ -1275,6 +1277,26 @@ int thread_get_inflight_fd( struct thread *thread, int client )
if (thread->sync) release_object( thread->sync );
@@ -1549,6 +1551,26 @@ int thread_get_inflight_fd( struct thread *thread, int client )
return -1;
}
@@ -75,33 +66,34 @@ index f7e5e5fabe8..506adfc0a6f 100644
+ /* grab reference since object can be destroyed while trying to wake up */
+ grab_object( &thread->obj );
+ thread->exit_poll = NULL;
+ wake_up( &thread->obj, 0 );
+ signal_sync( thread->sync );
+ release_object( &thread->obj );
+}
+
/* kill a thread on the spot */
void kill_thread( struct thread *thread, int violent_death )
{
@@ -1294,8 +1316,12 @@ void kill_thread( struct thread *thread, int violent_death )
@@ -1568,8 +1590,13 @@ void kill_thread( struct thread *thread, int violent_death )
}
kill_console_processes( thread, 0 );
abandon_mutexes( thread );
- wake_up( &thread->obj, 0 );
- signal_sync( thread->sync );
- if (violent_death) send_thread_signal( thread, SIGQUIT );
+ if (violent_death)
+ {
+ send_thread_signal( thread, SIGQUIT );
+ check_terminated( thread );
+ }
+ else wake_up( &thread->obj, 0 );
+ else
+ signal_sync( thread->sync );
cleanup_thread( thread );
remove_process_thread( thread->process, thread );
release_object( thread );
diff --git a/server/thread.h b/server/thread.h
index a1bc5060bb9..edf2a825451 100644
index 58081be7481..d87f84603ef 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -93,6 +93,7 @@ struct thread
@@ -95,6 +95,7 @@ struct thread
data_size_t desc_len; /* thread description length in bytes */
WCHAR *desc; /* thread description string */
struct completion_wait *completion_wait; /* completion port wait object the thread is associated with */
@@ -110,5 +102,5 @@ index a1bc5060bb9..edf2a825451 100644
extern struct thread *current;
--
2.45.2
2.47.2