* [PATCH 1/2] overlayfs: fix possible leak in ovl_new_inode
@ 2012-03-12 5:44 Robin Dong
2012-03-12 5:44 ` [PATCH 2/2] overlayfs: create new inode in ovl_link Robin Dong
0 siblings, 1 reply; 3+ messages in thread
From: Robin Dong @ 2012-03-12 5:44 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: root, Robin Dong
From: root <root@core097006.sqa.cm4>
After allocating a new inode, if the mode of inode is incorrect, we should release it
by iput().
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
fs/overlayfs/inode.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index ba1a777..b8ee72c 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -376,6 +376,7 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
default:
WARN(1, "illegal file type: %i\n", mode);
+ iput(inode);
inode = NULL;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] overlayfs: create new inode in ovl_link
2012-03-12 5:44 [PATCH 1/2] overlayfs: fix possible leak in ovl_new_inode Robin Dong
@ 2012-03-12 5:44 ` Robin Dong
2012-03-14 16:37 ` Miklos Szeredi
0 siblings, 1 reply; 3+ messages in thread
From: Robin Dong @ 2012-03-12 5:44 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: root, Robin Dong
From: root <root@core097006.sqa.cm4>
Imaging using ext4 as upperdir which has a file "hello" and lowdir is
totally empty.
1. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper /overlay
2. cd /overlay
3. ln hello bye
then the overlayfs code will call vfs_link to create a real ext4
dentry for "bye" and create
a new overlayfs dentry point to overlayfs inode (which standed for
"hello"). That means:
two overlayfs dentries and only one overlayfs inode.
and then
4. umount /overlay
5. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper
/overlay (again)
6. cd /overlay
7. ls hello bye
the overlayfs will create two inodes(one for the "hello", another
for the "bye") and two dentries (each point a inode).That means:
two dentries and two inodes.
As above, with different order of "create link" and "mount", the
result is not the same.
In order to make the behavior coherent, we need to create inode in ovl_link.
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
fs/overlayfs/dir.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 57bbb94..836132f 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -416,6 +416,7 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
struct dentry *olddentry;
struct dentry *newdentry;
struct dentry *upperdir;
+ struct inode *newinode;
err = ovl_copy_up(old);
if (err)
@@ -440,13 +441,17 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
err = -ENOENT;
goto out_unlock;
}
+ newinode = ovl_new_inode(old->d_sb, newdentry->d_inode->i_mode,
+ new->d_fsdata);
+ if (!newinode)
+ goto link_fail;
ovl_dentry_version_inc(new->d_parent);
ovl_dentry_update(new, newdentry);
- ihold(old->d_inode);
- d_instantiate(new, old->d_inode);
+ d_instantiate(new, newinode);
} else {
+link_fail:
if (ovl_dentry_is_opaque(new))
ovl_whiteout(upperdir, new);
dput(newdentry);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] overlayfs: create new inode in ovl_link
2012-03-12 5:44 ` [PATCH 2/2] overlayfs: create new inode in ovl_link Robin Dong
@ 2012-03-14 16:37 ` Miklos Szeredi
0 siblings, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2012-03-14 16:37 UTC (permalink / raw)
To: Robin Dong; +Cc: linux-fsdevel, Robin Dong
Robin Dong <hao.bigrat@gmail.com> writes:
> From: root <root@core097006.sqa.cm4>
Not sure what to make of this. Are you not the author of the patch?
Why isn't there a real name here?
Otherwise the patches look fine and I've applied them.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-14 16:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-12 5:44 [PATCH 1/2] overlayfs: fix possible leak in ovl_new_inode Robin Dong
2012-03-12 5:44 ` [PATCH 2/2] overlayfs: create new inode in ovl_link Robin Dong
2012-03-14 16:37 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).