* [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs
@ 2011-06-14 15:16 amir73il
2011-09-15 6:54 ` Amir G.
2011-09-16 2:23 ` Ted Ts'o
0 siblings, 2 replies; 3+ messages in thread
From: amir73il @ 2011-06-14 15:16 UTC (permalink / raw)
To: linux-ext4; +Cc: Amir Goldstein
From: Amir Goldstein <amir73il@users.sf.net>
The condition ((start+num) & ~0xffffffffULL) in bitmap_ragne2
and generic_bmap_range funcs in get_bitmap64.c was wrong and
inconsistent with the condition (start+num-1 > bmap->real_end)
in generic_bitmap_range funcs in get_bitmap.c.
I got the following error from tune2fs on a 16TB fs:
Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295
for block bitmap for 16TB.img
tune2fs: Invalid argument while reading bitmaps
Fix to condition to ((start+num-1) & ~0xffffffffULL), because
the bit (start+num) is not going to be changed by the funcs.
Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
---
lib/ext2fs/gen_bitmap64.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index df095ac..69c399a 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -382,7 +382,7 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num) & ~0xffffffffULL) {
+ if ((start+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
0xffffffff);
return EINVAL;
@@ -405,7 +405,7 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num) & ~0xffffffffULL) {
+ if ((start+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2(bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return EINVAL;
@@ -476,7 +476,7 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
bmap, block);
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return EINVAL;
@@ -498,7 +498,7 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
return;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return;
@@ -526,7 +526,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
return;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs
2011-06-14 15:16 [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs amir73il
@ 2011-09-15 6:54 ` Amir G.
2011-09-16 2:23 ` Ted Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Amir G. @ 2011-09-15 6:54 UTC (permalink / raw)
To: Theodore Tso; +Cc: Ext4 Developers List
On Tue, Jun 14, 2011 at 6:16 PM, <amir73il@users.sourceforge.net> wrote:
> From: Amir Goldstein <amir73il@users.sf.net>
>
> The condition ((start+num) & ~0xffffffffULL) in bitmap_ragne2
> and generic_bmap_range funcs in get_bitmap64.c was wrong and
> inconsistent with the condition (start+num-1 > bmap->real_end)
> in generic_bitmap_range funcs in get_bitmap.c.
>
> I got the following error from tune2fs on a 16TB fs:
> Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295
> for block bitmap for 16TB.img
> tune2fs: Invalid argument while reading bitmaps
>
> Fix to condition to ((start+num-1) & ~0xffffffffULL), because
> the bit (start+num) is not going to be changed by the funcs.
>
> Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
ping
> ---
> lib/ext2fs/gen_bitmap64.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
> index df095ac..69c399a 100644
> --- a/lib/ext2fs/gen_bitmap64.c
> +++ b/lib/ext2fs/gen_bitmap64.c
> @@ -382,7 +382,7 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
> return EINVAL;
>
> if (EXT2FS_IS_32_BITMAP(bmap)) {
> - if ((start+num) & ~0xffffffffULL) {
> + if ((start+num-1) & ~0xffffffffULL) {
> ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
> 0xffffffff);
> return EINVAL;
> @@ -405,7 +405,7 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
> return EINVAL;
>
> if (EXT2FS_IS_32_BITMAP(bmap)) {
> - if ((start+num) & ~0xffffffffULL) {
> + if ((start+num-1) & ~0xffffffffULL) {
> ext2fs_warn_bitmap2(bmap,
> EXT2FS_UNMARK_ERROR, 0xffffffff);
> return EINVAL;
> @@ -476,7 +476,7 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
> bmap, block);
>
> if (EXT2FS_IS_32_BITMAP(bmap)) {
> - if ((block+num) & ~0xffffffffULL) {
> + if ((block+num-1) & ~0xffffffffULL) {
> ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
> EXT2FS_UNMARK_ERROR, 0xffffffff);
> return EINVAL;
> @@ -498,7 +498,7 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
> return;
>
> if (EXT2FS_IS_32_BITMAP(bmap)) {
> - if ((block+num) & ~0xffffffffULL) {
> + if ((block+num-1) & ~0xffffffffULL) {
> ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
> EXT2FS_UNMARK_ERROR, 0xffffffff);
> return;
> @@ -526,7 +526,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
> return;
>
> if (EXT2FS_IS_32_BITMAP(bmap)) {
> - if ((block+num) & ~0xffffffffULL) {
> + if ((block+num-1) & ~0xffffffffULL) {
> ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
> EXT2FS_UNMARK_ERROR, 0xffffffff);
> return;
> --
> 1.7.4.1
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs
2011-06-14 15:16 [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs amir73il
2011-09-15 6:54 ` Amir G.
@ 2011-09-16 2:23 ` Ted Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Ted Ts'o @ 2011-09-16 2:23 UTC (permalink / raw)
To: amir73il; +Cc: linux-ext4, Amir Goldstein
On Tue, Jun 14, 2011 at 06:16:32PM +0300, amir73il@users.sourceforge.net wrote:
> From: Amir Goldstein <amir73il@users.sf.net>
>
> The condition ((start+num) & ~0xffffffffULL) in bitmap_ragne2
> and generic_bmap_range funcs in get_bitmap64.c was wrong and
> inconsistent with the condition (start+num-1 > bmap->real_end)
> in generic_bitmap_range funcs in get_bitmap.c.
>
> I got the following error from tune2fs on a 16TB fs:
> Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295
> for block bitmap for 16TB.img
> tune2fs: Invalid argument while reading bitmaps
>
> Fix to condition to ((start+num-1) & ~0xffffffffULL), because
> the bit (start+num) is not going to be changed by the funcs.
>
> Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-16 2:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14 15:16 [PATCH] libext2fs: fix the range validation in bitmap_range2 funcs amir73il
2011-09-15 6:54 ` Amir G.
2011-09-16 2:23 ` Ted Ts'o
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).