Skip to content

Commit 413ba91

Browse files
committed
ovl: fix dentry reference leak after changes to underlying layers
syzbot excercised 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-and-tested-by: [email protected] Signed-off-by: Amir Goldstein <[email protected]>
1 parent 98b1cc8 commit 413ba91

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/overlayfs/copy_up.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,16 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
753753
path.dentry = temp;
754754
err = ovl_copy_up_data(c, &path);
755755
/*
756-
* We cannot hold lock_rename() throughout this helper, because or
756+
* We cannot hold lock_rename() throughout this helper, because of
757757
* lock ordering with sb_writers, which shouldn't be held when calling
758758
* ovl_copy_up_data(), so lock workdir and destdir and make sure that
759759
* temp wasn't moved before copy up completion or cleanup.
760-
* If temp was moved, abort without the cleanup.
761760
*/
762761
ovl_start_write(c->dentry);
763762
if (lock_rename(c->workdir, c->destdir) != NULL ||
764763
temp->d_parent != c->workdir) {
764+
/* temp or workdir moved underneath us? abort without cleanup */
765+
dput(temp);
765766
err = -EIO;
766767
goto unlock;
767768
} else if (err) {

0 commit comments

Comments
 (0)