Skip to contentSkip to conversation

f2fs-tools: handle total_sectors is zero

PATCH New Jaegeuk Kim via Linux-f2fs-devel 1 participant 1 message Feb 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs-tools: handle total_sectors is zero

From: Maxim Pleshivenkov <[email protected]>

touch crash.img
./out/host/linux-x86/bin/make_f2fs -g android -b 16384 crash.img

    F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2023-04-11)

Info: Debug level = 1
Info: Trim is enabled
Info: Set conf for android
Info: Enable Project quota
Info: not exist /proc/version!
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 0 (0 MB)
Info: block size = 16384
Info: zone aligned segment0 blkaddr: 512
AddressSanitizer:DEADLYSIGNAL
=================================================================
==300581==ERROR: AddressSanitizer: FPE on unknown address 0x5625f4833664 (pc 0x5625f4833664 bp 0x7ffd7745c070 sp 0x7ffd7745bdd0 T0)

    #0 0x5625f4833664 in get_reserved external/f2fs-tools/include/f2fs_fs.h:1873:42
    #1 0x5625f4833664 in get_best_overprovision external/f2fs-tools/include/f2fs_fs.h:1900:14
    #2 0x5625f4833664 in f2fs_prepare_super_block external/f2fs-tools/mkfs/f2fs_format.c:579:21
    #3 0x5625f4833664 in f2fs_format_device external/f2fs-tools/mkfs/f2fs_format.c:1884:7
    #4 0x5625f4821e94 in main external/f2fs-tools/mkfs/f2fs_format_main.c:562:6
    #5 0x7fb54fe94ca7 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #6 0x7fb54fe94d64 in __libc_start_main csu/../csu/libc-start.c:360:3
    #7 0x5625f473b008 in _start (/usr/local/google/home/mpleshivenkov/src/b_479167542/main/out/host/linux-x86/bin/make_f2fs+0x9b008) (BuildId: 10870ae26d00ed4dfb428b9204c19b93)

==300581==Register values:

rax = 0x00000000ffffffff  rbx = 0x00000ac4be913cb8  rcx = 0x0000000000000000  rdx = 0x0000000000000000
rdi = 0x00005625f48a702c  rsi = 0x00000000ffffffff  rbp = 0x00007ffd7745c070  rsp = 0x00007ffd7745bdd0
 r8 = 0x00005625f4895da0   r9 = 0x00000000fffe96a3  r10 = 0x00000ac4be914e05  r11 = 0x00005625f489e5c0
r12 = 0x00005625f48a7014  r13 = 0x00000000fffe96a3  r14 = 0x00000ac4be914e02  r15 = 0x00000ac4be914e02

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE external/f2fs-tools/include/f2fs_fs.h:1873:42 in get_reserved ==300581==ABORTING

---
 mkfs/f2fs_format.c | 3 +++
 1 file changed, 3 insertions(+)
mkfs/f2fs_format.c +3 -0
index b3dccd0f010c..267297f344cb 100644
@@ -341,6 +341,9 @@ static int f2fs_prepare_super_block(void)
 
 	for (i = 0; i < c.ndevs; i++) {
 		if (i == 0) {
+			if (c.devices[i].total_sectors * c.sector_size <
+						zone_align_start_offset)
+				goto too_small;
 			c.devices[i].total_segments =
 				((c.devices[i].total_sectors *
 				c.sector_size - zone_align_start_offset) /
Signature · 8 lines
2.53.0.371.g1d285c8824-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel