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] [day] [month] [year] [list]
Date:   Tue, 20 Mar 2018 10:25:24 -0400
From:   "Theodore Y. Ts'o" <tytso@....edu>
To:     Kazuya Mio <k-mio@...jp.nec.com>
Cc:     "adilger.kernel@...ger.ca" <adilger.kernel@...ger.ca>,
        "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] libext2fs: fix to read the bitmaps for image file
 correctly

On Tue, Mar 20, 2018 at 06:42:29AM +0000, Kazuya Mio wrote:
> Thank you for your kind advices. However, after applying the patch,
> debugfs caused segfault by the following steps:
> 
> # mke2fs -t ext4 /dev/sda8
> # e2image /dev/sda8 test.img
> # debugfs -R stats -i test.img
> debugfs 1.44.0 (7-Mar-2018)
> Segmentation fault
> 
> According to the following backtrace, read_bitmaps() called by
> ext2fs_read_inode_bitmap() reads not only inode bitmap, but also block bitmap.
> We would need to consider about do_inode/do_block arguments in read_bitmaps().

Thanks for pointing that out.  I was using dumpe2fs to do my testing,
so I didn't notice that how debugfs was calling
ext2fs_read_inode_bitmap() and ext2fss_read_block_bitmap() separately.
I'll fix this up in the commit before I push it out.

diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 0c4fecc48..0b532dbf9 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -255,7 +255,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 	if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
 		blk = (fs->image_header->offset_inodemap / fs->blocksize);
 		ino_cnt = fs->super->s_inodes_count;
-		while (ino_cnt > 0) {
+		while (inode_bitmap && ino_cnt > 0) {
 			retval = io_channel_read_blk64(fs->image_io, blk++,
 						     1, inode_bitmap);
 			if (retval)
@@ -274,7 +274,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 		       fs->blocksize);
 		blk_cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super,
 						  fs->group_desc_count);
-		while (blk_cnt > 0) {
+		while (block_bitmap && blk_cnt > 0) {
 			retval = io_channel_read_blk64(fs->image_io, blk++,
 						     1, block_bitmap);
 			if (retval)


I'm also going to change debugfs to use ext2fs_read_bitmaps() since
for large file systems on a single HDD spindle, it's a significant
performance win to use ext2fs_read_bitmaps() since halves the number
of seeks need to pull in the bitmaps.

Regards,

						- Ted

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ