🇰🇷 한글 설명
Linux 커널의 hfsplus 파일시스템 드라이버에서 디스크 레코드 크기 검증 부재로 인해 초기화되지 않은 메모리 값이 사용되는 취약점입니다. 손상된 파일시스템을 마운트할 때 불완전한 데이터 읽기가 발생하며, 이는 KMSAN 경고와 함께 비정상적인 메모리 접근을 유발할 수 있습니다.
💡 쉬운 설명
손상된 HFS+ 파일시스템을 로드할 때 커널이 잘못된 크기의 데이터를 읽으며 안전하지 않은 메모리 값을 사용할 수 있습니다. 이는 시스템 불안정이나 예기치 않은 동작을 초래할 수 있는 중급 위험도 취약점입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
hfsplus: fix uninit-value by validating catalog record size
Syzbot reported a KMSAN uninit-value issue in hfsplus_strcasecmp(). The
root cause is that hfs_brec_read() doesn't validate that the on-disk
record size matches the expected size for the record type being read.
When mounting a corrupted filesystem, hfs_brec_read() may read less data
than expected. For example, when reading a catalog thread record, the
debug output showed:
HFSPLUS_BREC_READ: rec_len=520, fd->entrylength=26
HFSPLUS_BREC_READ: WARNING - entrylength (26) < rec_len (520) - PARTIAL READ!
hfs_brec_read() only validates that entrylength is not greater than the
buffer size, but doesn't check if it's less than expected. It successfully
reads 26 bytes into a 520-byte structure and returns success, leaving 494
bytes uninitialized.
This uninitialized data in tmp.thread.nodeName then gets copied by
hfsplus_cat_build_key_uni() and used by hfsplus_strcasecmp(), triggering
the KMSAN warning when the uninitialized bytes are used as array indices
in case_fold().
Fix by introducing hfsplus_brec_read_cat() wrapper that:
1. Calls hfs_brec_read() to read the data
2. Validates the record size based on the type field:
- Fixed size for folder and file records
- Variable size for thread records (depends on string length)
3. Returns -EIO if size doesn't match expected
For thread records, check against HFSPLUS_MIN_THREAD_SZ before reading
nodeName.length to avoid reading uninitialized data at call sites that
don't zero-initialize the entry structure.
Also initialize the tmp variable in hfsplus_find_cat() as defensive
programming to ensure no uninitialized data even if validation is
bypassed.
📍 영향받는 시스템
Linux kernel (hfsplus 모듈)
⚔️ 공격 벡터
손상된 HFS+ 파일시스템 이미지 또는 디바이스를 시스템에 마운트하여 악의적인 레코드 크기를 유도
🛡️ 대응 방법
Linux 커널 패치 적용 및 hfsplus 모듈 업데이트를 통해 레코드 크기 검증 로직 강화
🔧 검증 코드
출력된 커널 버전이 패치가 적용된 최신 안정 버전인지 확인하여 취약점이 해결되었는지 판단