Commit e8bd877f authored by Amir Goldstein's avatar Amir Goldstein
Browse files

ovl: fix possible double unlink



commit 9d23967b ("ovl: simplify an error path in
ovl_copy_up_workdir()") introduced the helper ovl_cleanup_unlocked(),
which is later used in several following patches to re-acquire the parent
inode lock and unlink a dentry that was earlier found using lookup.
This helper was eventually renamed to ovl_cleanup().

The helper ovl_parent_lock() is used to re-acquire the parent inode lock.
After acquiring the parent inode lock, the helper verifies that the
dentry has not since been moved to another parent, but it failed to
verify that the dentry wasn't unlinked from the parent.

This means that now every call to ovl_cleanup() could potentially
race with another thread, unlinking the dentry to be cleaned up
underneath overlayfs and trigger a vfs assertion.

Reported-by: default avatar <syzbot+ec9fab8b7f0386b98a17@syzkaller.appspotmail.com>
Tested-by: default avatar <syzbot+ec9fab8b7f0386b98a17@syzkaller.appspotmail.com>
Fixes: 9d23967b ("ovl: simplify an error path in ovl_copy_up_workdir()")
Suggested-by: default avatarNeilBrown <neil@brown.name>
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
parent 5f1c8965
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment