Skip to content

Commit e9c7008

Browse files
neilbrownbrauner
authored andcommitted
ovl: fail ovl_lock_rename_workdir() if either target is unhashed
As well as checking that the parent hasn't changed after getting the lock we need to check that the dentry hasn't been unhashed. Otherwise we might try to rename something that has been removed. Reported-by: syzbot+bfc9a0ccf0de47d04e8c@syzkaller.appspotmail.com Fixes: d2c9955 ("ovl: Call ovl_create_temp() without lock held.") Signed-off-by: NeilBrown <neil@brown.name> Link: https://patch.msgid.link/176429295510.634289.1552337113663461690@noble.neil.brown.name Tested-by: syzbot+bfc9a0ccf0de47d04e8c@syzkaller.appspotmail.com Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 7b6dcd9 commit e9c7008

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/overlayfs/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@ int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *work,
12341234
goto err;
12351235
if (trap)
12361236
goto err_unlock;
1237-
if (work && work->d_parent != workdir)
1237+
if (work && (work->d_parent != workdir || d_unhashed(work)))
12381238
goto err_unlock;
1239-
if (upper && upper->d_parent != upperdir)
1239+
if (upper && (upper->d_parent != upperdir || d_unhashed(upper)))
12401240
goto err_unlock;
12411241

12421242
return 0;

0 commit comments

Comments
 (0)