[lkml]   [2018]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: Cramfs: "unable to handle kernel paging request" when reading a file from a fuzzed FS image
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,
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)
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.


 \ /
  Last update: 2018-10-29 17:04    [W:0.046 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site