diff options
author | Amir Goldstein <amir73il@gmail.com> | 2017-06-05 21:44:49 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-07-04 22:03:15 +0200 |
commit | f681eb1d5c02c9e79775e10363057d034c720efc (patch) | |
tree | ea4f2c8b94ba19eacdd56a912a59187d3122ae17 /fs/overlayfs/dir.c | |
parent | Merge tag 'uuid-for-4.13' of git://git.infradead.org/users/hch/uuid into over... (diff) | |
download | linux-f681eb1d5c02c9e79775e10363057d034c720efc.tar.xz linux-f681eb1d5c02c9e79775e10363057d034c720efc.zip |
ovl: fix nlink leak in ovl_rename()
This patch fixes an overlay inode nlink leak in the case where
ovl_rename() renames over a non-dir.
This is not so critical, because overlay inode doesn't rely on
nlink dropping to zero for inode deletion.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | fs/overlayfs/dir.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index a63a71656e9b..fcfa7de12ad5 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -1046,6 +1046,13 @@ static int ovl_rename(struct inode *olddir, struct dentry *old, if (cleanup_whiteout) ovl_cleanup(old_upperdir->d_inode, newdentry); + if (overwrite && d_inode(new)) { + if (new_is_dir) + clear_nlink(d_inode(new)); + else + drop_nlink(d_inode(new)); + } + ovl_dentry_version_inc(old->d_parent); ovl_dentry_version_inc(new->d_parent); |