This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH 3/3] Cygwin: dll_list: query dll file id at load time
- From: Michael Haubenwallner <michael dot haubenwallner at ssi-schaefer dot com>
- To: cygwin-patches at cygwin dot com
- Cc: Michael Haubenwallner <michael dot haubenwallner at ssi-schaefer dot com>
- Date: Tue, 30 Apr 2019 16:15:30 +0200
- Subject: [PATCH 3/3] Cygwin: dll_list: query dll file id at load time
- References: <20190430141215.21230-1-michael.haubenwallner@ssi-schaefer.com>
NtQueryVirtualMemory for MemorySectionName does not reliable return the
changed dll file name when another process does move the file around,
and we may end up creating forkable hardlinks to wrong dll files.
So query the file id when loading the dll rather than before fork.
---
winsup/cygwin/dll_init.cc | 2 ++
winsup/cygwin/forkable.cc | 4 ----
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index 28f4e53a8..4ba1bd22d 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -380,6 +380,8 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
d->forkable_ntname = d->ntname + ntnamelen + 1;
*d->forkable_ntname = L'\0';
}
+ if (forkables_supported ())
+ d->stat_real_file_once (); /* uses nt_max_path_buf () */
append (d);
if (type == DLL_LOAD)
loaded_dlls++;
diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc
index 912a9ac8c..e78784c2f 100644
--- a/winsup/cygwin/forkable.cc
+++ b/winsup/cygwin/forkable.cc
@@ -605,10 +605,6 @@ dll_list::forkable_ntnamesize (dll_type type, PCWCHAR fullntname, PCWCHAR modnam
void
dll_list::prepare_forkables_nomination ()
{
- dll *d = &dlls.start;
- while ((d = d->next))
- d->stat_real_file_once (); /* uses nt_max_path_buf () */
-
PWCHAR pbuf = nt_max_path_buf ();
bool needsep = false;
--
2.19.2