diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-11-05 18:31:36 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-11-05 18:31:36 +0100 |
commit | 41299df081a0a7edc646caf84d208145624a1d37 (patch) | |
tree | f2e7f07b5b2ea37fc42cbbef99636f6b84aabeb4 /winsup | |
parent | eeef72702692fca52610634da32b56241e8083f3 (diff) | |
download | newlib-41299df081a0a7edc646caf84d208145624a1d37.zip newlib-41299df081a0a7edc646caf84d208145624a1d37.tar.gz newlib-41299df081a0a7edc646caf84d208145624a1d37.tar.bz2 |
Avoid deadlock in flock(2)
* fcntl.cc (fcntl64): Don't lock fd table when performing locking.
* flock.cc (flock): Ditto.
(lockf): Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/fcntl.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/flock.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/release/2.3.0 | 3 |
4 files changed, 16 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 456bcd1..73b8237 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2015-11-05 Corinna Vinschen <corinna@vinschen.de> + * fcntl.cc (fcntl64): Don't lock fd table when performing locking. + * flock.cc (flock): Ditto. + (lockf): Ditto. + +2015-11-05 Corinna Vinschen <corinna@vinschen.de> + * sigproc.cc (pending_signals::clear): Yet another fix to fix the fix. Actually iterate over the list of pending signals even if there's a signal which doesn't have to be cleared. Other than that, revert loop diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index babb064..cb97f68 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -1,7 +1,7 @@ /* fcntl.cc: fcntl syscall Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2008, 2009, - 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. + 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -32,7 +32,9 @@ fcntl64 (int fd, int cmd, ...) { debug_printf ("fcntl(%d, %d, ...)", fd, cmd); - cygheap_fdget cfd (fd, true); + + /* Don't lock the fd table when performing locking calls. */ + cygheap_fdget cfd (fd, cmd < F_GETLK || cmd > F_SETLKW); if (cfd < 0) __leave; diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index f26a76a..0ac5548 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -1,6 +1,6 @@ /* flock.cc. NT specific implementation of advisory file locking. - Copyright 2003, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. + Copyright 2003, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -1773,7 +1773,7 @@ flock (int fd, int operation) __try { - cygheap_fdget cfd (fd, true); + cygheap_fdget cfd (fd); if (cfd < 0) __leave; @@ -1817,7 +1817,7 @@ lockf (int filedes, int function, off_t size) __try { - cygheap_fdget cfd (filedes, true); + cygheap_fdget cfd (filedes); if (cfd < 0) __leave; diff --git a/winsup/cygwin/release/2.3.0 b/winsup/cygwin/release/2.3.0 index 0ec7d88..7375555 100644 --- a/winsup/cygwin/release/2.3.0 +++ b/winsup/cygwin/release/2.3.0 @@ -65,3 +65,6 @@ Bug Fixes - Workaround a bug in Windows 10 NLS handling. Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00547.html + +- Avoid unnecessry locking and thus a potential deadlock in flock(2). + Addresses: https://cygwin.com/ml/cygwin/2015-11/msg00095.html |