Whamcloud - gitweb
libext2fs: avoid looping forever in e2image when superblock is invalid
authorTheodore Ts'o <tytso@mit.edu>
Sat, 13 Aug 2022 20:39:17 +0000 (16:39 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 13 Aug 2022 20:39:17 +0000 (16:39 -0400)
commit28dce1ed0e7ff6cb89024d754570b954c329f2f6
tree0d07167cc6fd240feaa2a993051157e0c9478247
parent18ebcf26f478702cd09dd4229320d449469f1490
libext2fs: avoid looping forever in e2image when superblock is invalid

If the number of blocks or inodes per block group is not a multiple of
8 (which are invalid values) ext2fs_image_bitmap{read,write} can loop
forever.  These file systems should be not be allowed to be opened
(without EXT2_FLAG_IGNORE_SB_ERRORS) but for the fact that a long time
ago, Android devices used a buggy (but BSD-licensed, which was what
was important to the early Android founders) program for creating file
systems which would create these invalid file systems.  E2fsck
couldn't actually correctly repair these file systems, but adding a
check to enforce this (in e2fsprogs and in the kernel) would have
broken some of these devices, so support for these bogus file system
was in a grey area for many years.

We will be tightening this up soon, but for now, we'll apply this
quick fix so attempts to use e2image won't hang forever.  (Not that
Android ever shipped e2image in those days, of course...)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/imager.c