lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 29 Oct 2018 12:03:08 -0400 (EDT)
From:   Nicolas Pitre <nicolas.pitre@...aro.org>
To:     Anatoly Trosinenko <anatoly.trosinenko@...il.com>
cc:     linux-kernel@...r.kernel.org
Subject: Re: 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,
 			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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ