From: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
To: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Cramfs: "unable to handle kernel paging request" when reading a file from a fuzzed FS image
Date: Wed, 31 Oct 2018 16:06:53 +0300 [thread overview]
Message-ID: <CAE5jQCc+LjJOSxAvTLaf1Fh_pRKgTgeS0=kZKgBjBPg1n2B7_w@mail.gmail.com> (raw)
In-Reply-To: <nycvar.YSQ.7.76.1810291150231.1498@knanqh.ubzr>
Tested in fresh torvalds/master branch. Thank you!
Best regards
Anatoly
пн, 29 окт. 2018 г. в 19:03, Nicolas Pitre <nicolas.pitre@linaro.org>:
>
> On Mon, 29 Oct 2018, Anatoly Trosinenko wrote:
>
> > > How do I populate /vtmp? Mine is empty at this point. I imagine I
> > > should put the cramfs image somewhere on the host, but I'm not that
> > > familiar withkvm.
> >
> > Oops, forgot to say, it is the /tmp/kvm-xfstests-$USER directory on
> > the host (it will be created when you first launch kvm-xfstests and it
> > is "live", i.e. like NFS, not like "pack to ext4 image then boot and
> > mount").
>
> OK, I reproduced it. The fix is as follows:
>
> diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
> index f408994fc6..6e000392e4 100644
> --- a/fs/cramfs/inode.c
> +++ b/fs/cramfs/inode.c
> @@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
> continue;
> blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT;
> blk_offset += offset;
> - if (blk_offset + len > BUFFER_SIZE)
> + if (blk_offset > BUFFER_SIZE ||
> + blk_offset + len > BUFFER_SIZE)
> continue;
> return read_buffers[i] + blk_offset;
> }
>
> User space will get a bunch of zeroes rather than an explicit error in
> this case. There is just so many ways to corrupt a cramfs image without
> detecting it afterwards that I don't think it is worth doing more than
> making sure the system won't be compromized.
>
> > > Hmmm... It doesn't show up on my test system.
> >
> > Mounted it on my host Ubuntu 18.10 amd64, executed `cat /mnt/xyz` and
> > it was "Killed". Maybe it is something freshly added or
> > arch-dependent...
>
> It actually depends on whether there is something mapped immediately
> next to the cramfs cache buffer.
>
> In any case, this is a nice catch. Thank you for reporting it.
>
>
> Nicolas
prev parent reply other threads:[~2018-10-31 13:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAE5jQCdhWVVqf8en9S-3mbDBwuxk481S+hi-uvQSw6Gf6jKujQ@mail.gmail.com>
2018-10-29 3:43 ` Cramfs: "unable to handle kernel paging request" when reading a file from a fuzzed FS image Nicolas Pitre
2018-10-29 7:13 ` Anatoly Trosinenko
2018-10-29 16:03 ` Nicolas Pitre
2018-10-31 13:06 ` Anatoly Trosinenko [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='CAE5jQCc+LjJOSxAvTLaf1Fh_pRKgTgeS0=kZKgBjBPg1n2B7_w@mail.gmail.com' \
--to=anatoly.trosinenko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.pitre@linaro.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).