🇰🇷 한글 설명
Linux 커널의 F2FS 파일 시스템에서 압축 기능이 활성화된 inode를 해제할 때, 정렬되지 않은 크기로 파일 크기를 줄이는(truncation) 작업이 허용되어 데이터가 손상되는 취약점입니다. 이로 인해 파일 시스템의 블록 카운트와 실제 블록 수가 일치하지 않아 파일 시스템 무결성이 깨질 수 있습니다.
💡 쉬운 설명
압축 기능을 사용하는 파일 시스템에서 파일 크기를 조절할 때 계산 오류가 발생하여 파일 데이터가 깨질 수 있는 문제입니다. 잘못된 방식으로 파일 크기를 줄이면 저장된 데이터가 엉망이 될 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: compress: don't allow unaligned truncation on released compress inode
f2fs image may be corrupted after below testcase:
- mkfs.f2fs -O extra_attr,compression -f /dev/vdb
- mount /dev/vdb /mnt/f2fs
- touch /mnt/f2fs/file
- f2fs_io setflags compression /mnt/f2fs/file
- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=4
- f2fs_io release_cblocks /mnt/f2fs/file
- truncate -s 8192 /mnt/f2fs/file
- umount /mnt/f2fs
- fsck.f2fs /dev/vdb
[ASSERT] (fsck_chk_inode_blk:1256) --> ino: 0x5 has i_blocks: 0x00000002, but has 0x3 blocks
[FSCK] valid_block_count matching with CP [Fail] [0x4, 0x5]
[FSCK] other corrupted bugs [Fail]
The reason is: partial truncation assume compressed inode has reserved
blocks, after partial truncation, valid block count may change w/o
.i_blocks and .total_valid_block_count update, result in corruption.
This patch only allow cluster size aligned truncation on released
compress inode for fixing.
📍 영향받는 시스템
Linux Kernel (F2FS 파일 시스템 사용 환경)
⚔️ 공격 벡터
로컬 사용자가 압축된 F2FS 파일에 대해 정렬되지 않은 크기로 truncate 작업을 수행하여 파일 시스템 손상 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 F2FS의 압축 inode truncation 로직 수정 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인