linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Dan Carpenter <error27@gmail.com>
Cc: jack@suse.cz, linux-ext4@vger.kernel.org
Subject: Re: [bug report] ext4: Fix possible corruption when moving a directory
Date: Tue, 7 Mar 2023 19:18:47 +0000	[thread overview]
Message-ID: <ZAeOFzbhCNvskQ6b@gmail.com> (raw)
In-Reply-To: <5efbe1b9-ad8b-4a4f-b422-24824d2b775c@kili.mountain>

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).

- Eric

  reply	other threads:[~2023-03-07 19:33 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 [this message]
2023-03-08 10:42   ` Jan Kara
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=ZAeOFzbhCNvskQ6b@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=error27@gmail.com \
    --cc=jack@suse.cz \
    --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).