🇰🇷 한글 설명
Linux 커널의 NILFS2 파일 시스템에서 remount 과정 중 발생하는 Use-After-Free 취약점입니다. 파일 시스템이 읽기 전용으로 전환되거나 다시 읽기/쓰기 모드로 마운트될 때, 로그 라이터 객체가 해제된 후 다시 접근되어 메모리 오류를 유발할 수 있습니다.
💡 쉬운 설명
파일 시스템의 설정이 바뀌는 과정에서 이미 삭제된 메모리 정보를 다시 사용하려고 시도하여 시스템이 충돌하거나 보안 문제가 생길 수 있는 오류입니다. 이는 주로 파일 시스템의 데이터가 손상되었을 때 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nilfs2: fix use-after-free bug of ns_writer on remount
If a nilfs2 filesystem is downgraded to read-only due to metadata
corruption on disk and is remounted read/write, or if emergency read-only
remount is performed, detaching a log writer and synchronizing the
filesystem can be done at the same time.
In these cases, use-after-free of the log writer (hereinafter
nilfs->ns_writer) can happen as shown in the scenario below:
Task1 Task2
-------------------------------- ------------------------------
nilfs_construct_segment
nilfs_segctor_sync
init_wait
init_waitqueue_entry
add_wait_queue
schedule
nilfs_remount (R/W remount case)
nilfs_attach_log_writer
nilfs_detach_log_writer
nilfs_segctor_destroy
kfree
finish_wait
_raw_spin_lock_irqsave
__raw_spin_lock_irqsave
do_raw_spin_lock
debug_spin_lock_before <-- use-after-free
While Task1 is sleeping, nilfs->ns_writer is freed by Task2. After Task1
waked up, Task1 accesses nilfs->ns_writer which is already freed. This
scenario diagram is based on the Shigeru Yoshida's post [1].
This patch fixes the issue by not detaching nilfs->ns_writer on remount so
that this UAF race doesn't happen. Along with this change, this patch
also inserts a few necessary read-only checks with superblock instance
where only the ns_writer pointer was used to check if the filesystem is
read-only.
📍 영향받는 시스템
NILFS2 파일 시스템을 사용하는 Linux 커널 버전
⚔️ 공격 벡터
손상된 디스크 메타데이터를 이용한 파일 시스템 remount 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인합니다.