bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fchdir on mingw


From: Eric Blake
Subject: Re: fchdir on mingw
Date: Mon, 31 Aug 2009 19:26:30 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 8/31/2009 5:38 PM:
> Notice that this changes the status of fdopendir - whereas it was previously 
> non-multithread safe and could call _exit, the mingw version of fdopendir is 
> now threadsafe and avoids _exit.

Well, not entirely threadsafe.  There is a window between when rpl_open()
does a stat() to learn that name is a directory, and when fchdir/fdopendir
(via chdir()/opendir()) uses that name later on.  It's not as pronounced
on mingw, where you can't rename an in-use directory (and we could even
open up a directory HANDLE to prevent users from changing it behind our
backs), but it probably is asking for problems on Unix if another process
is actively changing the same hierarchy as what we just tied to the fchdir
metadata table.  So on second thought, for systems with fchdir and which
can open() directories without help, I'd rather stick with
save_cwd/fchdir/opendir/restore_cwd rather than risk an optimized
fdopendir that exposes the user to a multi-process data race.  At least
with the fchdir approach to fdopendir, you have limited your problems only
to a race between threads in a single process, rather than something
exploitable by other processes.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqceEYACgkQ84KuGfSFAYCkQACeJsHocH5U2USkxI9aP/HG2B8f
kVoAoIPtnTxbHHFgX7RnX8VQuoEC+7sE
=TAb9
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]