UDF overflow fix and cleanups
Subsystems (2)
Jan Kara
reviewercover UDF overflow fix and cleanups
Hi,
I've added the three patches in this series to my tree and plan to
merge them in the next merge window. The first patch fixes an overflow in handling large filesystems with small block size, the other two patches are just cleanups.
Honza
Jan Kara
reviewerPATCH 1/3 udf: Fix bitmap overflow on large filesystems with small block size
For large UDF filesystems with 512-byte blocks the number of necessary bitmap blocks is larger than 2^16 so s_nr_groups in udf_bitmap overflows (the number will overflow for filesystems larger than 128 GB with 512-byte blocks). That results in ENOSPC errors despite the filesystem has plenty of free space.
Fix the problem by changing s_nr_groups' type to 'int'. That is enough even for filesystems 2^32 blocks (UDF maximum) and 512-byte blocksize.
--- fs/udf/udf_sb.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/udf/udf_sb.h +1 -1
@@ -82,7 +82,7 @@ struct udf_virtual_data {struct udf_bitmap {__u32 s_extLength;__u32 s_extPosition; -__u16 s_nr_groups; +int s_nr_groups;struct buffer_head **s_block_bitmap; };
Signature · 1 line
1.7.1
Jan Kara
reviewerPATCH 2/3 udf: Make s_block_bitmap standard array
In reply to Jan Karastruct udf_bitmap has array of buffer pointers attached to it. The code unnecessarily used s_block_bitmap as a pointer to the array instead of the standard trick of using 0 length array in the declaration. Change that to make code more readable and actually shrink the structure by one pointer.
--- fs/udf/super.c | 1 - fs/udf/udf_sb.h | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)
fs/udf/super.c +0 -1
@@ -1023,7 +1023,6 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)if (bitmap ==NULL )return NULL ; - bitmap->s_block_bitmap = (struct buffer_head **)(bitmap +1 ); bitmap->s_nr_groups = nr_groups;return bitmap; }
fs/udf/udf_sb.h +1 -1
@@ -83,7 +83,7 @@ struct udf_bitmap {__u32 s_extLength;__u32 s_extPosition;int s_nr_groups; -struct buffer_head **s_block_bitmap; +struct buffer_head *s_block_bitmap[0 ]; };struct udf_part_map {
Signature · 1 line
1.7.1
Jan Kara
reviewerPATCH 3/3 udf: Remove unused s_extLength from udf_bitmap
In reply to Jan Karas_extLength was assigned to but the value was never really used. So just remove the field.
--- fs/udf/super.c | 4 ---- fs/udf/udf_sb.h | 1 - 2 files changed, 0 insertions(+), 5 deletions(-)
fs/udf/super.c +0 -4
@@ -1080,8 +1080,6 @@ static int udf_fill_partdesc_info(struct super_block *sb,if (!bitmap)return 1 ; map->s_uspace.s_bitmap = bitmap; - bitmap->s_extLength =le32_to_cpu ( - phd->unallocSpaceBitmap.extLength); bitmap->s_extPosition =le32_to_cpu ( phd->unallocSpaceBitmap.extPosition); map->s_partition_flags |=UDF_PART_FLAG_UNALLOC_BITMAP ;
@@ -1116,8 +1114,6 @@ static int udf_fill_partdesc_info(struct super_block *sb,if (!bitmap)return 1 ; map->s_fspace.s_bitmap = bitmap; - bitmap->s_extLength =le32_to_cpu ( - phd->freedSpaceBitmap.extLength); bitmap->s_extPosition =le32_to_cpu ( phd->freedSpaceBitmap.extPosition); map->s_partition_flags |=UDF_PART_FLAG_FREED_BITMAP ;
fs/udf/udf_sb.h +0 -1
@@ -80,7 +80,6 @@ struct udf_virtual_data { };struct udf_bitmap { -__u32 s_extLength;__u32 s_extPosition;int s_nr_groups;struct buffer_head *s_block_bitmap[0 ];
Signature · 1 line
1.7.1