🇰🇷 한글 설명
Linux 커널의 F2FS 파일 시스템에서 nat_entry 플래그를 잘못 사용하여 데이터 손실이 발생할 수 있는 취약점입니다. 체크포인트 작업과 fsync 작업이 동시에 수행될 때, 체크포인트가 완료되지 않았음에도 완료된 것으로 잘못 판단하여 파일이 유실될 수 있습니다.
💡 쉬운 설명
파일을 저장하는 과정에서 시스템이 '저장이 완료되었다'고 착각하여 실제로는 저장이 안 된 데이터를 지워버릴 수 있는 문제입니다. 이로 인해 새로 만든 파일이 갑자기 사라지는 데이터 손실이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix data loss caused by incorrect use of nat_entry flag
Data loss can occur when fsync is performed on a newly created file
(before any checkpoint has been written) concurrently with a checkpoint
operation. The scenario is as follows:
create & write & fsync 'file A' write checkpoint
- f2fs_do_sync_file // inline inode
- f2fs_write_inode // inode folio is dirty
- f2fs_write_checkpoint
- f2fs_flush_merged_writes
- f2fs_sync_node_pages
- f2fs_flush_nat_entries
- f2fs_fsync_node_pages // no dirty node
- f2fs_need_inode_block_update // return false
SPO and lost 'file A'
f2fs_flush_nat_entries() sets the IS_CHECKPOINTED and HAS_LAST_FSYNC
flags for the nat_entry, but this does not mean that the checkpoint has
actually completed successfully. However, f2fs_need_inode_block_update()
checks these flags and incorrectly assumes that the checkpoint has
finished.
The root cause is that the semantics of IS_CHECKPOINTED and
HAS_LAST_FSYNC are only guaranteed after the checkpoint write fully
completes.
This patch modifies f2fs_need_inode_block_update() to acquire the
sbi->node_write lock before reading the nat_entry flags, ensuring that
once IS_CHECKPOINTED and HAS_LAST_FSYNC are observed to be set, the
checkpoint operation has already completed.
📍 영향받는 시스템
Linux kernel (F2FS 파일 시스템을 사용하는 시스템)
⚔️ 공격 벡터
사용자 또는 애플리케이션이 특정 타이밍에 파일 생성, 쓰기, fsync 작업을 동시에 수행하여 유도
🛡️ 대응 방법
F2FS 관련 패치가 적용된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인