🇰🇷 한글 설명
Linux 커널의 ext4 파일시스템에서 EXT4_IOC_MIGRATE ioctl 호출 시 i_data_sem 잠금 순서 문제로 인한 데드락이 발생할 수 있습니다. CONFIG_PROVE_LOCKING이 활성화된 환경에서 O_SYNC 플래그로 열린 파일에 마이그레이션 작업과 쓰기 시스템 콜이 경합할 때 jbd2 핸들 잠금으로 인해 교착 상태가 발생합니다.
💡 쉬운 설명
파일 시스템 마이그레이션 작업 중에 데이터 잠금 순서가 잘못되어 프로세스가 무한 대기하는 문제입니다. O_SYNC 옵션으로 열린 파일에서 발생하며, 커널 검증 옵션이 활성화된 경우에만 나타납니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ext4: fix i_data_sem unlock order in ext4_ind_migrate()
Fuzzing reports a possible deadlock in jbd2_log_wait_commit.
This issue is triggered when an EXT4_IOC_MIGRATE ioctl is set to require
synchronous updates because the file descriptor is opened with O_SYNC.
This can lead to the jbd2_journal_stop() function calling
jbd2_might_wait_for_commit(), potentially causing a deadlock if the
EXT4_IOC_MIGRATE call races with a write(2) system call.
This problem only arises when CONFIG_PROVE_LOCKING is enabled. In this
case, the jbd2_might_wait_for_commit macro locks jbd2_handle in the
jbd2_journal_stop function while i_data_sem is locked. This triggers
lockdep because the jbd2_journal_start function might also lock the same
jbd2_handle simultaneously.
Found by Linux Verification Center (linuxtesting.org) with syzkaller.
Rule: add
📍 영향받는 시스템
Linux 커널 (ext4 파일시스템 사용, CONFIG_PROVE_LOCKING 활성화)
⚔️ 공격 벡터
EXT4_IOC_MIGRATE ioctl을 O_SYNC 플래그로 열린 파일 디스크립터에 적용하면서 동시에 쓰기 작업 수행
🛡️ 대응 방법
Linux 커널을 최신 패치 버전으로 업그레이드하여 i_data_sem 잠금 순서 수정 적용
🔧 검증 코드
커널 버전과 CONFIG_PROVE_LOCKING, CONFIG_EXT4_FS 설정 상태를 확인하여 취약한 환경인지 판단합니다.
uname -r && cat /boot/config-$(uname -r) 2>/dev/null | grep -E 'CONFIG_PROVE_LOCKING|CONFIG_EXT4_FS'