From: Carlos Maiolino <cmaiolino@redhat.com>
To: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: fix guard_bio_eod to check for real EOD errors
Date: Fri, 22 Feb 2019 15:47:46 +0100 [thread overview]
Message-ID: <20190222144746.vwre45gnl5gkvqvr@hades.usersys.redhat.com> (raw)
In-Reply-To: <20190222141311.24694-1-cmaiolino@redhat.com>
> MNT=/mnt
> IMG=./DISK.img
> DEV=/dev/loop0
>
My apologies. I forgot to mention I had ./DISK.img already created in my working
tree, it's a simple
`dd if=/dev/zero of=./DISK.img bs=1m count=20`.
The image should be slighter larger than 16247280, so the FS attempts to step
out of the device.
> mkfs.vfat $IMG
> mount $IMG $MNT
> cp -R /etc $MNT &> /dev/null
> umount $MNT
>
> losetup -D
>
> losetup --find --show --sizelimit 16247280 $IMG
> mount $DEV $MNT
>
> find $MNT -type f -exec cat {} + >/dev/null
>
> Kudos to Eric Sandeen for coming up with the reproducer above
>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>
> P.S. I'm not 100% proficient in bio internals, so I'm not sure if this is the
> right fix, so comments are much appreciated.
> Thanks
>
> fs/buffer.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 784de3dbcf28..32dc5cd2f6ba 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -3063,6 +3063,13 @@ void guard_bio_eod(int op, struct bio *bio)
> /* Uhhuh. We've got a bio that straddles the device size! */
> truncated_bytes = bio->bi_iter.bi_size - (maxsector << 9);
>
> + /*
> + * The bio contains more than one segment which spans EOD, just return
> + * and let IO layer turn it into an EIO
> + */
> + if (truncated_bytes > PAGE_SIZE)
> + return;
> +
> /* Truncate the bio.. */
> bio->bi_iter.bi_size -= truncated_bytes;
> bvec->bv_len -= truncated_bytes;
> --
> 2.17.2
>
--
Carlos
next prev parent reply other threads:[~2019-02-22 14:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 14:13 [PATCH] fs: fix guard_bio_eod to check for real EOD errors Carlos Maiolino
2019-02-22 14:47 ` Carlos Maiolino [this message]
2019-02-22 23:33 ` Ming Lei
2019-02-24 21:36 ` Dave Chinner
2019-02-25 13:26 ` Carlos Maiolino
2019-02-26 2:03 ` Ming Lei
2019-02-26 9:37 ` Carlos Maiolino
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=20190222144746.vwre45gnl5gkvqvr@hades.usersys.redhat.com \
--to=cmaiolino@redhat.com \
--cc=linux-fsdevel@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).