Linux filesystem development
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, Ye Bin <yebin10@huawei.com>,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH] unbugger ext2_empty_dir()
Date: Mon, 28 Nov 2022 11:41:02 +0100	[thread overview]
Message-ID: <20221128104102.phypw45xcfrtrw7d@quack3> (raw)
In-Reply-To: <Y4GFPajUjIBOa5i2@ZenIV>

On Sat 26-11-22 03:17:17, Al Viro wrote:
> 	In 27cfa258951a "ext2: fix fs corruption when trying to remove
> a non-empty directory with IO error" a funny thing has happened:
> 
> -               page = ext2_get_page(inode, i, dir_has_error, &page_addr);
> +               page = ext2_get_page(inode, i, 0, &page_addr);
>  
>  -               if (IS_ERR(page)) {
>  -                       dir_has_error = 1;
>  -                       continue;
>  -               }
>  +               if (IS_ERR(page))
>  +                       goto not_empty;
> 
> And at not_empty: we hit ext2_put_page(page, page_addr), which does
> put_page(page).  Which, unless I'm very mistaken, should oops
> immediately when given ERR_PTR(-E...) as page.
> 
> OK, shit happens, insufficiently tested patches included.  But when
> commit in question describes the fault-injection test that exercised
> that particular failure exit...
> 
> Ow.
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Right. I've clearly missed this when reviewing & merging the fix. And Ye
Bin obviously didn't test this with his reproducer ;). Anyway, thanks for
catching this! I've merged the patch to my tree.

								Honza

> ---
> diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
> index 8f597753ac12..5202eddfc3c0 100644
> --- a/fs/ext2/dir.c
> +++ b/fs/ext2/dir.c
> @@ -679,7 +679,7 @@ int ext2_empty_dir (struct inode * inode)
>  		page = ext2_get_page(inode, i, 0, &page_addr);
>  
>  		if (IS_ERR(page))
> -			goto not_empty;
> +			return 0;
>  
>  		kaddr = page_addr;
>  		de = (ext2_dirent *)kaddr;
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2022-11-28 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-26  3:17 [PATCH] unbugger ext2_empty_dir() Al Viro
2022-11-28 10:41 ` Jan Kara [this message]

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=20221128104102.phypw45xcfrtrw7d@quack3 \
    --to=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yebin10@huawei.com \
    /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