[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 01/53: trans/fakeroot: fix cached node retrieval on lookup
From: |
Samuel Thibault |
Subject: |
[hurd] 01/53: trans/fakeroot: fix cached node retrieval on lookup |
Date: |
Thu, 20 Mar 2014 02:23:49 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 1ea83c98a8fb8f58a4de8368d1fa29d341a2a73c
Author: Richard Braun <address@hidden>
Date: Fri Feb 7 22:54:24 2014 +0100
trans/fakeroot: fix cached node retrieval on lookup
When a client finds a node from the hash table, it could happen that
another thread is still holding one reference on it before the current
thread has acquired its own. Simply checking for a non zero refcount isn't
enough, the new client must atomically acquire its own reference.
* trans/fakeroot.c (netfs_S_dir_lookup): Find and acquire node reference
while holding netfs_node_refcnt_lock.
---
trans/fakeroot.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 3038612..c519180 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -348,6 +348,10 @@ netfs_S_dir_lookup (struct protid *diruser,
redo_hash_lookup:
pthread_mutex_lock (&idport_ihash_lock);
pthread_mutex_lock (&dnp->lock);
+ /* The hashtable may not hold a true reference on the node. Acquire the
+ refcount lock so that, if a node is found, its reference counter cannot
+ drop to 0 before we get our own reference. */
+ pthread_spin_lock (&netfs_node_refcnt_lock);
struct netnode *nn = hurd_ihash_find (&idport_ihash, idport);
if (nn != NULL)
{
@@ -359,12 +363,17 @@ netfs_S_dir_lookup (struct protid *diruser,
/* But it might be in the process of being released. If so,
unlock the hash table to give the node a chance to actually
be removed and retry. */
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
pthread_mutex_unlock (&dnp->lock);
pthread_mutex_unlock (&idport_ihash_lock);
goto redo_hash_lookup;
}
+ /* Otherwise, reference it right away. */
np = nn->np;
+ np->references++;
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
+
mach_port_deallocate (mach_task_self (), idport);
if (np == dnp)
@@ -377,12 +386,12 @@ netfs_S_dir_lookup (struct protid *diruser,
pthread_mutex_unlock (&dnp->lock);
}
- netfs_nref (np);
err = check_openmodes (np->nn, (flags & (O_RDWR|O_EXEC)), file);
pthread_mutex_unlock (&idport_ihash_lock);
}
else
{
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
err = new_node (file, idport, 1, flags, &np);
pthread_mutex_unlock (&dnp->lock);
if (!err)
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 11/53: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, (continued)
- [hurd] 11/53: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/03/19
- [hurd] 09/53: libdiskfs: fix typo, Samuel Thibault, 2014/03/19
- [hurd] 13/53: Add missing copyright notice, Samuel Thibault, 2014/03/19
- [hurd] 42/53: mach-defpager: add and use synchronized_printf for dprintf, Samuel Thibault, 2014/03/19
- [hurd] 05/53: fatfs: add bz2 to OTHERLIBS, Samuel Thibault, 2014/03/19
- [hurd] 07/53: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/03/19
- [hurd] 31/53: libdiskfs: fix receiver lookups in fsys server functions, Samuel Thibault, 2014/03/19
- [hurd] 43/53: mach-defpager: fix error handling in S_default_pager_object_set_size, Samuel Thibault, 2014/03/19
- [hurd] 03/53: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/03/19
- [hurd] 39/53: auth: improve the mig mutator functions, Samuel Thibault, 2014/03/19
- [hurd] 01/53: trans/fakeroot: fix cached node retrieval on lookup,
Samuel Thibault <=
- [hurd] 10/53: Add missing copyright notice, Samuel Thibault, 2014/03/19
- [hurd] 06/53: Fix typos, Samuel Thibault, 2014/03/19
- [hurd] 19/53: utils/umount: do not remove passive translator records, Samuel Thibault, 2014/03/19
- [hurd] 16/53: pfinet: set a non-zero ports management timeout, Samuel Thibault, 2014/03/19
- [hurd] 14/53: libstore: fixed some pointer-sign related warnings, Samuel Thibault, 2014/03/19
- [hurd] 22/53: mach-defpager: add function mig_reply_setup, Samuel Thibault, 2014/03/19
- [hurd] 17/53: exec: provide a meaningful name for new tasks, Samuel Thibault, 2014/03/19
- [hurd] 20/53: libpager: improve the pager_demuxer function, Samuel Thibault, 2014/03/19
- [hurd] 21/53: mach-defpager: fix definition of seqnos_memory_object_data_unlock, Samuel Thibault, 2014/03/19
- [hurd] 23/53: mach-defpager: improve the default_pager_demux_object function, Samuel Thibault, 2014/03/19