Skip to content

Commit

Permalink
ovl: fix dentry reference leak after changes to underlying layers
Browse files Browse the repository at this point in the history
syzbot excersized the forbidden practice of moving the workdir under
lowerdir while overlayfs is mounted and tripped a dentry reference leak.

Fixes: c63e56a ("ovl: do not open/llseek lower file with upper sb_writers held")
Reported-by: syzbot+8608bb4553edb8c78f41@syzkaller.appspotmail.com
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
  • Loading branch information
amir73il committed Dec 17, 2023
1 parent 98b1cc8 commit 79f938e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/overlayfs/copy_up.c
Expand Up @@ -753,15 +753,16 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
path.dentry = temp;
err = ovl_copy_up_data(c, &path);
/*
* We cannot hold lock_rename() throughout this helper, because or
* We cannot hold lock_rename() throughout this helper, because of
* lock ordering with sb_writers, which shouldn't be held when calling
* ovl_copy_up_data(), so lock workdir and destdir and make sure that
* temp wasn't moved before copy up completion or cleanup.
* If temp was moved, abort without the cleanup.
*/
ovl_start_write(c->dentry);
if (lock_rename(c->workdir, c->destdir) != NULL ||
temp->d_parent != c->workdir) {
/* temp moved while wdir was unlocked? abort without cleanup */
dput(temp);
err = -EIO;
goto unlock;
} else if (err) {
Expand Down

0 comments on commit 79f938e

Please sign in to comment.