提交 8994023e 编写于 作者: Z Zheng Liang 提交者: Yang Yingliang

ovl: fix missing negative dentry check in ovl_rename()

mainline inclusion
from mainline-v5.15-rc5
commit a295aef6
category: bugfix
bugzilla: NA
CVE: NA

-------------------------------------------------

The following reproducer

  mkdir lower upper work merge
  touch lower/old
  touch lower/new
  mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
  rm merge/new
  mv merge/old merge/new & unlink upper/new

may result in this race:

PROCESS A:
  rename("merge/old", "merge/new");
  overwrite=true,ovl_lower_positive(old)=true,
  ovl_dentry_is_whiteout(new)=true -> flags |= RENAME_EXCHANGE

PROCESS B:
  unlink("upper/new");

PROCESS A:
  lookup newdentry in new_upperdir
  call vfs_rename() with negative newdentry and RENAME_EXCHANGE

Fix by adding the missing check for negative newdentry.
Signed-off-by: NZheng Liang <zhengliang6@huawei.com>
Fixes: e9be9d5e ("overlay filesystem")
Cc: <stable@vger.kernel.org> # v3.18
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 5a7b4a79
...@@ -1186,9 +1186,13 @@ static int ovl_rename(struct inode *olddir, struct dentry *old, ...@@ -1186,9 +1186,13 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
goto out_dput; goto out_dput;
} }
} else { } else {
if (!d_is_negative(newdentry) && if (!d_is_negative(newdentry)) {
(!new_opaque || !ovl_is_whiteout(newdentry))) if (!new_opaque || !ovl_is_whiteout(newdentry))
goto out_dput; goto out_dput;
} else {
if (flags & RENAME_EXCHANGE)
goto out_dput;
}
} }
if (olddentry == trap) if (olddentry == trap)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册