linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Dan Carpenter <error27@gmail.com>,
	jack@suse.cz, linux-ext4@vger.kernel.org
Subject: Re: [bug report] ext4: Fix possible corruption when moving a directory
Date: Wed, 8 Mar 2023 11:42:34 +0100	[thread overview]
Message-ID: <20230308104234.z7vmgmjz2smepwlg@quack3> (raw)
In-Reply-To: <ZAeOFzbhCNvskQ6b@gmail.com>

On Tue 07-03-23 19:18:47, Eric Biggers wrote:
> On Tue, Mar 07, 2023 at 06:56:28PM +0300, Dan Carpenter wrote:
> > Hello Jan Kara,
> > 
> > The patch 0813299c586b: "ext4: Fix possible corruption when moving a
> > directory" from Jan 26, 2023, leads to the following Smatch static
> > checker warning:
> > 
> > 	fs/ext4/namei.c:4017 ext4_rename()
> > 	error: double unlocked '&old.inode->i_rwsem' (orig line 3882)
> > 
> [...]
> >     3875                 /*
> >     3876                  * We need to protect against old.inode directory getting
> >     3877                  * converted from inline directory format into a normal one.
> >     3878                  */
> >     3879                 inode_lock_nested(old.inode, I_MUTEX_NONDIR2);
> >     3880                 retval = ext4_rename_dir_prepare(handle, &old);
> >     3881                 if (retval) {
> >     3882                         inode_unlock(old.inode);
> > 
> > The issue here is that ext4_rename_dir_prepare() sets old.dir_bh and
> > then returns -EFSCORRUPTED.  It results in an unlock here and then again
> > after the goto.
> 
> That analysis looks correct.  FYI, I think this is the same as the syzbot report
> "[ext4?] WARNING: bad unlock balance in ext4_rename2"
> (https://lore.kernel.org/linux-ext4/000000000000435c6905f639ae8e@google.com).

Good spotting! This should be fixed (along with the lock ordering problem)
by 3c92792da8506 ("ext4: Fix deadlock during directory rename") Ted has
just merged couple hours ago.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2023-03-08 10:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 15:56 [bug report] ext4: Fix possible corruption when moving a directory Dan Carpenter
2023-03-07 19:18 ` Eric Biggers
2023-03-08 10:42   ` Jan Kara [this message]
2023-03-18  2:07     ` Theodore Ts'o
2023-03-20 11:03       ` Jan Kara

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=20230308104234.z7vmgmjz2smepwlg@quack3 \
    --to=jack@suse.cz \
    --cc=ebiggers@kernel.org \
    --cc=error27@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    /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).