several fixes from tree-in-dcache stuff
Subsystems (5)
Al Viro
maintainerPATCH 1/1 several fixes from tree-in-dcache stuff
Several fixes for fairly old crap - qibfs leak, a couple of spufs ones and a spufs double-dput() memory corruptor.
This stuff sits in viro/vfs.git#fixes; individual patches in followups. Review would be very welcome.
Al Viro
maintainerPATCH 1/4 spufs: fix a leak on spufs_new_file() failure
It's called from spufs_fill_dir(), and caller of that will do spufs_rmdir() in case of failure. That does remove everything we'd managed to create, but... the problem dentry is still negative. IOW, it needs to be explicitly dropped.
--- arch/powerpc/platforms/cell/spufs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/platforms/cell/spufs/inode.c +3 -1
@@ -192,8 +192,10 @@ static int spufs_fill_dir(struct dentry *dir,return -ENOMEM ; ret =spufs_new_file (dir->d_sb, dentry, files->ops, files->mode & mode, files->size, ctx); -if (ret) +if (ret) { +dput (dentry);return ret; + } files++; }return 0 ;
Signature · 1 line
2.39.5
Re: [PATCH 1/4] spufs: fix a leak on spufs_new_file() failure
Quoted 8 lines · Al Viro
It's called from
spufs_fill_dir(), and caller of that will dospufs_rmdir()in case of failure. That does remove everything we'd managed to create, but... the problem dentry is still negative. IOW, it needs to be explicitly dropped.Fixes 3f51dd91c807 "[PATCH] spufs: fix spufs_fill_dir error path"Signed-off-by Al Viro <[email protected]>---
Al Viro
maintainerPATCH 2/4 spufs: fix gang directory lifetimes
In reply to Al Viroprior to "[POWERPC] spufs: Fix gang destroy leaks" we used to have a problem with gang lifetimes - creation of a gang returns opened gang directory, which normally gets removed when that gets closed, but if somebody has created a context belonging to that gang and kept it alive until the gang got closed, removal failed and we ended up with a leak.
Unfortunately, it had been fixed the wrong way. Dentry of gang directory was no longer pinned, and rmdir on close was gone. One problem was that failure of open kept calling simple_rmdir() as cleanup, which meant an unbalanced dput(). Another bug was in the success case - gang creation incremented link count on root directory, but that was no longer undone when gang got destroyed.
Fix consists of
* reverting the commit in question
* adding a counter to gang, protected by ->i_rwsem
of gang directory inode.
* having it set to 1 at creation time, dropped
in both spufs_dir_close() and spufs_gang_close() and bumped in spufs_create_context(), provided that it's not 0.
* using simple_recursive_removal() to take the gang
directory out when counter reaches zero.
--- arch/powerpc/platforms/cell/spufs/gang.c | 1 + arch/powerpc/platforms/cell/spufs/inode.c | 54 +++++++++++++++++++---- arch/powerpc/platforms/cell/spufs/spufs.h | 2 + 3 files changed, 49 insertions(+), 8 deletions(-)
arch/powerpc/platforms/cell/spufs/gang.c +1 -0
@@ -25,6 +25,7 @@ struct spu_gang *alloc_spu_gang(void)mutex_init (&gang->aff_mutex);INIT_LIST_HEAD (&gang->list);INIT_LIST_HEAD (&gang->aff_list_head); + gang->alive =1 ; out:return gang;
arch/powerpc/platforms/cell/spufs/inode.c +46 -8
111 lines not on this page · raw message
arch/powerpc/platforms/cell/spufs/spufs.h +2 -0
@@ -151,6 +151,8 @@ struct spu_gang {int aff_flags;struct spu *aff_ref_spu;atomic_t aff_sched_count; + +int alive; };/* Flag bits for spu_gang aff_flags */
Signature · 1 line
2.39.5
Re: [PATCH 2/4] spufs: fix gang directory lifetimes
Quoted 25 lines · Al Viro
prior to "[POWERPC] spufs: Fix gang destroy leaks" we used to have a problem with gang lifetimes - creation of a gang returns opened gang directory, which normally gets removed when that gets closed, but if somebody has created a context belonging to that gang and kept it alive until the gang got closed, removal failed and we ended up with a leak.
Unfortunately, it had been fixed the wrong way. Dentry of gang directory was no longer pinned, and rmdir on close was gone. One problem was that failure of open kept calling
simple_rmdir()as cleanup, which meant an unbalanceddput(). Another bug was in the success case - gang creation incremented link count on root directory, but that was no longer undone when gang got destroyed.Fix consists of
* reverting the commit in question
* adding a counter to gang, protected by ->i_rwsem
of gang directory inode.
* having it set to 1 at creation time, dropped
in bothspufs_dir_close()andspufs_gang_close()and bumped inspufs_create_context(), provided that it's not 0.
* usingsimple_recursive_removal()to take the gang
directory out when counter reaches zero.
Quoted 3 lines
Fixes 877907d37da9 "[POWERPC] spufs: Fix gang destroy leaks"Signed-off-by Al Viro <[email protected]>---
Al Viro
maintainerPATCH 3/4 spufs: fix a leak in spufs_create_context()
In reply to Al ViroLeak fixes back in 2008 missed one case - if we are trying to set affinity and spufs_mkdir() fails, we need to drop the reference to neighbor.
--- arch/powerpc/platforms/cell/spufs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/platforms/cell/spufs/inode.c +4 -1
@@ -460,8 +460,11 @@ spufs_create_context(struct inode *inode, struct dentry *dentry, } ret =spufs_mkdir (inode, dentry, flags, mode &0777 ); -if (ret) +if (ret) { +if (neighbor) +put_spu_context (neighbor); goto out_aff_unlock; + }if (affinity) { spufs_set_affinity(flags, SPUFS_I(d_inode(dentry))->i_ctx,
Signature · 1 line
2.39.5
Re: [PATCH 3/4] spufs: fix a leak in spufs_create_context()
Quoted 6 lines · Al Viro
Leak fixes back in 2008 missed one case - if we are trying to set affinity and
spufs_mkdir()fails, we need to drop the reference to neighbor.Fixes 58119068cb27 "[POWERPC] spufs: Fix memory leak on SPU affinity"Signed-off-by Al Viro <[email protected]>---
Al Viro
maintainerPATCH 4/4 qibfs: fix _another_ leak
In reply to Al Virofailure to allocate inode => leaked dentry...
this one had been there since the initial merge; to be fair, if we are that far OOM, the odds of failing at that particular allocation are low...
--- drivers/infiniband/hw/qib/qib_fs.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/qib/qib_fs.c +1 -0
@@ -55,6 +55,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,struct inode *inode =new_inode (dir->i_sb);if (!inode) { +dput (dentry); error = -EPERM ; goto bail; }
Signature · 1 line
2.39.5
Re: [PATCH 4/4] qibfs: fix _another_ leak
Quoted 8 lines · Al Viro
failure to allocate inode => leaked dentry...
this one had been there since the initial merge; to be fair, if we are that far OOM, the odds of failing at that particular allocation are low...
Signed-off-by Al Viro <[email protected]>---