🇰🇷 한글 설명
Linux 커널의 F2FS 파일 시스템에서 fallocate 작업과 블록 할당 간의 경쟁 상태(Race Condition)로 인해 발생하는 취약점입니다. 가비지 컬렉션(GC) 과정에서 방금 할당된 세그먼트를 잘못 이동시켜 SSA와 SIT 간의 데이터 불일치를 유발하고 파일 시스템을 중단시킵니다.
💡 쉬운 설명
파일을 저장하는 과정에서 두 가지 작업이 동시에 일어나 충돌이 발생하면, 컴퓨터가 데이터가 꼬였다고 판단하여 파일 시스템을 강제로 멈춰버리는 문제입니다. 이로 인해 데이터 읽기/쓰기가 중단될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to avoid migrating empty section
It reports a bug from device w/ zufs:
F2FS-fs (dm-64): Inconsistent segment (173822) type [1, 0] in SSA and SIT
F2FS-fs (dm-64): Stopped filesystem due to reason: 4
Thread A Thread B
- f2fs_expand_inode_data
- f2fs_allocate_pinning_section
- f2fs_gc_range
- do_garbage_collect w/ segno #x
- writepage
- f2fs_allocate_data_block
- new_curseg
- allocate segno #x
The root cause is: fallocate on pinning file may race w/ block allocation
as above, result in do_garbage_collect() from fallocate() may migrate
segment which is just allocated by a log, the log will update segment type
in its in-memory structure, however GC will get segment type from on-disk
SSA block, once segment type changes by log, we can detect such
inconsistency, then shutdown filesystem.
In this case, on-disk SSA shows type of segno #173822 is 1 (SUM_TYPE_NODE),
however segno #173822 was just allocated as data type segment, so in-memory
SIT shows type of segno #173822 is 0 (SUM_TYPE_DATA).
Change as below to fix this issue:
- check whether current section is empty before gc
- add sanity checks on do_garbage_collect() to avoid any race case, result
in migrating segment used by log.
- btw, it fixes misc issue in printed logs: "SSA and SIT" -> "SIT and SSA".
📍 영향받는 시스템
F2FS 파일 시스템을 사용하는 Linux 커널 (zufs 장치 사용 시 발생 가능)
⚔️ 공격 벡터
로컬 사용자가 특정 파일에 대해 fallocate 작업을 수행하여 가비지 컬렉션 프로세스와의 경쟁 상태를 유도
🛡️ 대응 방법
F2FS 관련 패치가 적용된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 수정된 최신 패치 버전인지 확인