[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 71/98: trans: fix locking in fakeroot's netfs_S_dir_lookup
From: |
Samuel Thibault |
Subject: |
[hurd] 71/98: trans: fix locking in fakeroot's netfs_S_dir_lookup |
Date: |
Tue, 14 Jan 2014 02:00:03 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 61c77d679840e4c4455615295ac30215bb01cdf5
Author: Justus Winter <address@hidden>
Date: Mon Dec 9 14:33:17 2013 +0100
trans: fix locking in fakeroot's netfs_S_dir_lookup
* trans/fakeroot.c (netfs_S_dir_lookup): Fix locking.
---
trans/fakeroot.c | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index eff5225..d5cb0e6 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -322,7 +322,10 @@ netfs_S_dir_lookup (struct protid *diruser,
np = 0;
err = io_identity (file, &idport, &fsidport, &fileno);
if (err)
- mach_port_deallocate (mach_task_self (), file);
+ {
+ mach_port_deallocate (mach_task_self (), file);
+ return err;
+ }
else
{
mach_port_deallocate (mach_task_self (), fsidport);
@@ -335,6 +338,7 @@ netfs_S_dir_lookup (struct protid *diruser,
else
{
pthread_mutex_lock (&idport_ihash_lock);
+ pthread_mutex_lock (&dnp->lock);
struct netnode *nn = hurd_ihash_find (&idport_ihash, idport);
if (nn != NULL)
{
@@ -342,33 +346,38 @@ netfs_S_dir_lookup (struct protid *diruser,
np = nn->np;
/* We already know about this node. */
mach_port_deallocate (mach_task_self (), idport);
- pthread_mutex_lock (&np->lock);
- err = check_openmodes (np->nn, (flags & (O_RDWR|O_EXEC)), file);
- if (!err)
+
+ if (np == dnp)
{
- /* If the looked-up file carries a fake reference, we
- use that and clear the FAKE_REFERENCE flag. */
- if (np->nn->faked & FAKE_REFERENCE)
- np->nn->faked &= ~FAKE_REFERENCE;
- else
- netfs_nref (np);
+ /* dnp is already locked. */
}
- pthread_mutex_unlock (&np->lock);
+ else
+ {
+ pthread_mutex_lock (&np->lock);
+ pthread_mutex_unlock (&dnp->lock);
+ }
+
+ /* If the looked-up file carries a fake reference, we
+ use that and clear the FAKE_REFERENCE flag. */
+ if (np->nn->faked & FAKE_REFERENCE)
+ np->nn->faked &= ~FAKE_REFERENCE;
+ else
+ netfs_nref (np);
+
+ err = check_openmodes (np->nn, (flags & (O_RDWR|O_EXEC)), file);
pthread_mutex_unlock (&idport_ihash_lock);
}
else
{
err = new_node (file, idport, 1, flags, &np);
+ pthread_mutex_unlock (&dnp->lock);
if (!err)
- {
- pthread_mutex_unlock (&np->lock);
- err = netfs_validate_stat (np, diruser->user);
- }
+ err = netfs_validate_stat (np, diruser->user);
}
}
}
if (err)
- return err;
+ goto lose;
if (retry_name[0] == '\0' && *do_retry == FS_RETRY_NORMAL)
flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS|O_NONBLOCK);
@@ -393,7 +402,9 @@ netfs_S_dir_lookup (struct protid *diruser,
}
}
- netfs_nrele (np);
+ lose:
+ if (np != NULL)
+ netfs_nput (np);
return err;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 58/98: trans: remove unused declaration from fakeroot.c, (continued)
- [hurd] 58/98: trans: remove unused declaration from fakeroot.c, Samuel Thibault, 2014/01/13
- [hurd] 72/98: trans: fix reference counting bug in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 39/98: proc: update comments, Samuel Thibault, 2014/01/13
- [hurd] 26/98: Make sure created netfs nodes have stat validated, Samuel Thibault, 2014/01/13
- [hurd] 53/98: proc: improve the message_demuxer function, Samuel Thibault, 2014/01/13
- [hurd] 04/98: utils: implement settrans --pid-file, Samuel Thibault, 2014/01/13
- [hurd] 59/98: trans: improve the netfs_demuxer function in fakeroot.c, Samuel Thibault, 2014/01/13
- [hurd] 48/98: libports: another right leak fix, Samuel Thibault, 2014/01/13
- [hurd] 73/98: trans: improve the error handling in fakeauth, Samuel Thibault, 2014/01/13
- [hurd] 06/98: proc: fix the declaraton of genpid, Samuel Thibault, 2014/01/13
- [hurd] 71/98: trans: fix locking in fakeroot's netfs_S_dir_lookup,
Samuel Thibault <=
- [hurd] 70/98: trans: fix reference counting and destruction of fake nodes, Samuel Thibault, 2014/01/13
- [hurd] 77/98: trans/fakeroot: fix ownership of newly created files, Samuel Thibault, 2014/01/13
- [hurd] 64/98: libihash: remove dead code, Samuel Thibault, 2014/01/13
- [hurd] 74/98: trans: unlock nodes with faked attributes in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 75/98: console-client: remove spurious pthread_spin_unlocks, Samuel Thibault, 2014/01/13
- [hurd] 62/98: trans: make the fakeroot environment more transparent, Samuel Thibault, 2014/01/13
- [hurd] 14/98: proc: turn count_up and store_pid into normal functions, Samuel Thibault, 2014/01/13
- [hurd] 67/98: trans: handle invalid responses to dir_lookup requests in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 78/98: trans/fakeroot: drop else, Samuel Thibault, 2014/01/13
- [hurd] 13/98: term: fix error handling in hurdio_mdmctl, Samuel Thibault, 2014/01/13