From: Jan Kara <jack@suse.cz>
To: Baokun Li <libaokun1@huawei.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com,
linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
yangerkun@huawei.com, yukuai3@huawei.com,
syzbot+08106c4b7d60702dbc14@syzkaller.appspotmail.com
Subject: Re: [PATCH] ext4: check iomap type only if ext4_iomap_begin() does not fail
Date: Fri, 5 May 2023 18:50:56 +0200 [thread overview]
Message-ID: <20230505165056.7yjsh5nlaf4blvh5@quack3> (raw)
In-Reply-To: <20230505132429.714648-1-libaokun1@huawei.com>
On Fri 05-05-23 21:24:29, Baokun Li wrote:
> When ext4_iomap_overwrite_begin() calls ext4_iomap_begin() map blocks may
> fail for some reason (e.g. memory allocation failure, bare disk write), and
> later because "iomap->type ! = IOMAP_MAPPED" triggers WARN_ON(). When ext4
> iomap_begin() returns an error, it is normal that the type of iomap->type
> may not match the expectation. Therefore, we only determine if iomap->type
> is as expected when ext4_iomap_begin() is executed successfully.
>
> Reported-by: syzbot+08106c4b7d60702dbc14@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/all/00000000000015760b05f9b4eee9@google.com
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
Makes sense. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 0d5ba922e411..19c884abe52b 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3375,7 +3375,7 @@ static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset,
> */
> flags &= ~IOMAP_WRITE;
> ret = ext4_iomap_begin(inode, offset, length, flags, iomap, srcmap);
> - WARN_ON_ONCE(iomap->type != IOMAP_MAPPED);
> + WARN_ON_ONCE(!ret && iomap->type != IOMAP_MAPPED);
> return ret;
> }
>
> --
> 2.31.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-05-05 16:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 13:24 [PATCH] ext4: check iomap type only if ext4_iomap_begin() does not fail Baokun Li
2023-05-05 16:50 ` Jan Kara [this message]
2023-05-13 4:59 ` Theodore Ts'o
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=20230505165056.7yjsh5nlaf4blvh5@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=libaokun1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--cc=syzbot+08106c4b7d60702dbc14@syzkaller.appspotmail.com \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@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