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  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:   Wed, 14 Dec 2022 14:21:07 -0700
From:   Andreas Dilger <adilger@...ger.ca>
To:     "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Cc:     Theodore Ts'o <tytso@....edu>, linux-ext4@...r.kernel.org,
        Harshad Shirwadkar <harshadshirwadkar@...il.com>,
        Wang Shilong <wangshilong1991@...il.com>, Li Xi <lixi@....com>
Subject: Re: [RFCv1 17/72] libext2fs: Add support for
 ext2fs_test_block_bitmap_range2_valid()

On Nov 7, 2022, at 5:21 AM, Ritesh Harjani (IBM) <ritesh.list@...il.com> wrote:
> 
> From: Wang Shilong <wshilong@....com>
> 
> This adds the support in libext2fs to query whether the block range is
> valid or not (within range) given the block bitmap.
> Also to avoid duplicate warning messages in case of invalid blocks.
> 
> This will be later used in pass1 of e2fsck is_blocks_used() function to
> check whether the given block range is valid or not to avoid duplicate
> warning resulting from ext2fs_test_block_bitmap_range2()
> 
> Signed-off-by: Wang Shilong <wshilong@....com>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>

I don't think this patch is correct?

> ---
> diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
> index c31f942f..a9637cb5 100644
> --- a/lib/ext2fs/gen_bitmap64.c
> +++ b/lib/ext2fs/gen_bitmap64.c
> @@ -731,6 +731,39 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
> 	return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num);
> }
> 
> +int ext2fs_test_block_bitmap_range2_valid(ext2fs_block_bitmap bitmap,
> +					  blk64_t block, unsigned int num)
> +{
> +	ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64)bitmap;
> +	__u64	end = block + num;
> +
> +	if (!bmap)
> +		return 0;
> +
> +	if (EXT2FS_IS_32_BITMAP(bmap)) {
> +		if ((block & ~0xffffffffULL) ||
> +		    ((block+num-1) & ~0xffffffffULL)) {
> +			return 0;
> +		}
> +	}

This is bailing out early if the requested bit is > 2^32, but that is
before cluster conversion below.  However, I think the bitmap is actually
stored in clusters, so the 2^32 check seems premature?

> +
> +	if (!EXT2FS_IS_64_BITMAP(bmap))
> +		return 0;
> +
> +	/* convert to clusters if necessary */
> +	block >>= bmap->cluster_bits;
> +	end += (1 << bmap->cluster_bits) - 1;
> +	end >>= bmap->cluster_bits;
> +	num = end - block;
> +
> +	if ((block < bmap->start) || (block > bmap->end) ||
> +	    (block+num-1 > bmap->end))
> +		return 0;
> +
> +	return 1;
> +}

Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists