tytso / e2fsprogs

Ext2/3/4 file system utilities
http://ext4.wiki.kernel.org
383 stars 224 forks source link

Division by zero in e2fsck #183

Closed nbars closed 7 months ago

nbars commented 7 months ago

Hey,

I found division by zero leading to a SIGFPE. The error is caused by the following EXT2_DESC_PER_BLOCK macro invocation https://github.com/tytso/e2fsprogs/blob/260dfea450e387cbd2c8de79a7c2eeacc26f74e9/lib/ext2fs/openfs.c#L391

The macro is defined here https://github.com/tytso/e2fsprogs/blob/260dfea450e387cbd2c8de79a7c2eeacc26f74e9/lib/ext2fs/ext2_fs.h#L301

Best, Nils

==1889605==ERROR: AddressSanitizer: FPE on unknown address 0x7ffff7da0b85 (pc 0x7ffff7da0b85 bp 0x000000000001 sp 0x7fffffffdf50 T0)
    #0 0x7ffff7da0b85 in ext2fs_open2 e2fsprogs/afl/e2fsprogs-1.47.0/debian/BUILD-STD/lib/ext2fs/../../../../lib/ext2fs/openfs.c:391:12
    #1 0x5555556fe733 in try_open_fs e2fsprogs/afl/e2fsprogs-1.47.0/debian/BUILD-STD/e2fsck/../../../e2fsck/unix.c:0:0
    #2 0x5555556e6804 in main e2fsprogs/afl/e2fsprogs-1.47.0/debian/BUILD-STD/e2fsck/../../../e2fsck/unix.c:1524:11
    #3 0x7ffff780fa8f in __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #4 0x7ffff780fb48 in __libc_start_main ./csu/../csu/libc-start.c:360:3
    #5 0x5555555a75a4 in _start ??:0:0

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE (e2fsprogs/afl/e2fsprogs-1.47.0/debian/tmp/lib/x86_64-linux-gnu/libext2fs.so.2+0x207b85)
==1889605==ABORTING
tytso commented 7 months ago

Thanks for the report!