From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+8608bb4553edb8c78f41@syzkaller.appspotmail.com
Cc: amir73il@gmail.com, chao@kernel.org, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
phillip@squashfs.org.uk, reiserfs-devel@vger.kernel.org,
squashfs-devel@lists.sourceforge.net,
syzkaller-bugs@googlegroups.com, terrelln@fb.com,
viro@zeniv.linux.org.uk
Subject: [PATCH] ovl: fix BUG: Dentry still in use in unmount
Date: Sun, 17 Dec 2023 16:11:26 +0800 [thread overview]
Message-ID: <tencent_4E2FCFC90D97A5910DFA926DDD945D9B1907@qq.com> (raw)
In-Reply-To: <0000000000003362ba060ca8beac@google.com>
workdir and destdir could be the same when copying up to indexdir.
Fixes: c63e56a4a652 ("ovl: do not open/llseek lower file with upper sb_writers held")
Reported-and-tested-by: syzbot+8608bb4553edb8c78f41@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/overlayfs/copy_up.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 4382881b0709..ae5eb442025d 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -731,10 +731,14 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
.rdev = c->stat.rdev,
.link = c->link
};
+ err = -EIO;
+ /* workdir and destdir could be the same when copying up to indexdir */
+ if (lock_rename(c->workdir, c->destdir) != NULL)
+ goto unlock;
err = ovl_prep_cu_creds(c->dentry, &cc);
if (err)
- return err;
+ goto unlock;
ovl_start_write(c->dentry);
inode_lock(wdir);
@@ -743,8 +747,9 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
ovl_end_write(c->dentry);
ovl_revert_cu_creds(&cc);
+ err = PTR_ERR(temp);
if (IS_ERR(temp))
- return PTR_ERR(temp);
+ goto unlock;
/*
* Copy up data first and then xattrs. Writing data after
@@ -760,10 +765,9 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
* 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) {
+ if (temp->d_parent != c->workdir) {
err = -EIO;
- goto unlock;
+ goto unlockcd;
} else if (err) {
goto cleanup;
}
@@ -801,16 +805,18 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
ovl_inode_update(inode, temp);
if (S_ISDIR(inode->i_mode))
ovl_set_flag(OVL_WHITEOUTS, inode);
+
+unlockcd:
+ ovl_end_write(c->dentry);
unlock:
unlock_rename(c->workdir, c->destdir);
- ovl_end_write(c->dentry);
return err;
cleanup:
ovl_cleanup(ofs, wdir, temp);
dput(temp);
- goto unlock;
+ goto unlockcd;
}
/* Copyup using O_TMPFILE which does not require cross dir locking */
--
2.43.0
next prev parent reply other threads:[~2023-12-17 8:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 10:50 [syzbot] BUG: Dentry still in use in unmount syzbot
2023-12-16 23:19 ` [syzbot] [reiserfs?] [squashfs?] " syzbot
2023-12-17 8:11 ` Edward Adam Davis [this message]
2023-12-17 9:32 ` [PATCH] ovl: fix " Amir Goldstein
2023-12-17 9:16 ` [syzbot] [reiserfs?] [squashfs?] " Amir Goldstein
2023-12-17 9:36 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_4E2FCFC90D97A5910DFA926DDD945D9B1907@qq.com \
--to=eadavis@qq.com \
--cc=amir73il@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@squashfs.org.uk \
--cc=reiserfs-devel@vger.kernel.org \
--cc=squashfs-devel@lists.sourceforge.net \
--cc=syzbot+8608bb4553edb8c78f41@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=terrelln@fb.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).