4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-31 19:40:33 +08:00
Corinna Vinschen 2f05de4dbf Cygwin: fix all usages of NtQueryDirectoryObject
Due to reports on the Cygwin mailing list[1][2], it was uncovered
that a NtOpenDirectoryObject/NtQueryDirectoryObject/NtClose sequence
with NtQueryDirectoryObject iterating over the directory entries,
one entry per invocation, is not running atomically.  If new entries
are inserted into the queried directory, other entries may be moved
around and then accidentally show up twice while iterating.

Change (almost) all NtQueryDirectoryObject invocations so that it gets
a really big buffer (64K) and ideally fetches all entries at once.
This appears to work atomically.

"Almost" all, because fhandler_procsys::readdir can't be easily changed.

[1] https://cygwin.com/pipermail/cygwin/2021-July/248998.html
[2] https://cygwin.com/pipermail/cygwin/2021-August/249124.html

Fixes: e9c8cb31930bd ("(format_proc_partitions): Revamp loop over existing harddisks by scanning the NT native \Device object directory and looking for Harddisk entries.")
Fixes: a998dd7055766 ("Implement advisory file locking.")
Fixes: 3b7cd74bfdf56 ("(winpids::enum_processes): Fetch Cygwin processes from listing of shared cygwin object dir in the native NT namespace.")
Fixes: 0d6f2b0117aa7 ("syscalls.cc (sync_worker): Rewrite using native NT functions.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-08-19 16:42:23 +02:00
..
2020-05-30 19:41:18 +02:00
2021-08-02 13:57:03 +02:00
2021-04-27 16:49:56 +01:00
2016-06-25 00:43:01 +02:00
2021-02-01 09:55:08 -05:00
2021-07-30 15:48:26 +01:00
2018-02-20 17:59:53 +01:00
2021-02-01 09:55:08 -05:00
2020-08-28 11:10:48 +02:00
2020-10-18 14:55:13 +01:00
2021-07-30 15:48:26 +01:00
2021-06-26 15:24:27 +01:00
2017-03-27 22:03:58 +01:00
2015-08-17 11:05:43 +02:00
2021-07-30 15:48:26 +01:00
2020-08-28 11:10:48 +02:00
2021-07-29 17:13:47 +02:00
2018-04-16 22:46:11 -05:00
2020-08-30 09:33:30 -04:00
2021-07-29 17:13:47 +02:00
2019-06-25 15:44:43 -04:00
2019-06-25 15:44:43 -04:00