🇰🇷 한글 설명
Zephyr OS의 ext2 파일 시스템에서 슈퍼블록의 s_blocks_per_group 및 s_inodes_per_group 필드가 0인지 검증하지 않는 취약점이 발견되었습니다. 공격자가 조작된 ext2 이미지를 제공할 경우, 마운트 과정에서 0으로 나누기 연산이 발생하여 시스템이 UsageFault와 함께 중단될 수 있습니다.
💡 쉬운 설명
파일 시스템을 읽을 때 숫자를 0으로 나누는 계산 오류가 발생하여 기기가 멈추는 문제입니다. 악성 파일이 담긴 USB나 SD 카드를 꽂으면 기기가 작동을 멈출 수 있습니다.
🇺🇸 원문 (English)
The Zephyr ext2 file system validates the on-disk superblock in ext2_verify_disk_superblock() (subsys/fs/ext2/ext2_impl.c) before completing a mount. The validator checked the magic number, block size, revision and feature flags, but did not verify that the on-disk fields s_blocks_per_group and s_inodes_per_group are non-zero. Both fields are read directly from the image and are later used as divisors during mount-time initialization.
During mount, get_ngroups() divides and modulos s_blocks_count by s_blocks_per_group (reached via ext2_fetch_block_group() from ext2_init_fs()), and get_itable_entry() divides (ino - 1) by s_inodes_per_group when fetching the root inode (both in subsys/fs/ext2/ext2_diskops.c). A superblock with either field set to zero therefore causes an integer division by zero during the mount sequence.
An attacker who can present a crafted ext2 image to a device that mounts ext2 — removable media such as an SD card or a USB mass-storage device — can trigger this. On ARMv7-M / ARMv8-M-mainline Cortex-M targets, divide-by-zero trapping is enabled (SCB_CCR_DIV_0_TRP), so the division raises a UsageFault that Zephyr treats as a fatal error, producing a denial of service. The impact is limited to availability; the malformed value is consumed only as a divisor.
The fix rejects a zero s_blocks_per_group or s_inodes_per_group in the superblock validator, returning -EINVAL so the mount fails before any block-group or inode I/O occurs.
📍 영향받는 시스템
Zephyr OS (ext2 파일 시스템을 사용하는 ARMv7-M/ARMv8-M 기반 시스템)
⚔️ 공격 벡터
조작된 ext2 파일 시스템이 포함된 SD 카드 또는 USB 저장 장치를 대상 기기에 연결
🛡️ 대응 방법
슈퍼블록 검증 로직을 업데이트하여 s_blocks_per_group 또는 s_inodes_per_group가 0인 경우 마운트를 거부하도록 패치 적용
🔧 검증 코드
패치된 코드에서 해당 필드가 0인지 확인하는 조건문(예: if (sb->s_blocks_per_group == 0) return -EINVAL;)이 존재하는지 확인합니다.
grep -r "s_blocks_per_group" subsys/fs/ext2/ext2_impl.c
📊 CVSS Vector String
CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
💻 영향받는 소프트웨어
Windows iSCSI Target Service