🇰🇷 한글 설명
Linux 커널의 CIFS 파일 시스템에서 마운트 해제 후에도 사용 중인 dentry가 남아 있어 발생하는 취약점입니다. 특정 커밋 이후 CIFS 파일이 superblock에 대한 참조를 유지하지 않게 되면서, 마운트 해제 과정 중 지연된 작업이 실행될 때 경고(BUG)를 유발할 수 있습니다.
💡 쉬운 설명
파일을 다 쓰고 나서 시스템에서 연결을 끊을 때, 아직 정리되지 않은 파일 정보가 남아 있어 시스템에 오류 경고를 일으키는 문제입니다. 이로 인해 시스템이 불안정해지거나 예상치 못한 동작이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
cifs: Fix busy dentry used after unmounting
Since commit 340cea84f691c ("cifs: open files should not hold ref on
superblock"), cifs file only holds the dentry ref_cnt, the cifs file
close work(cfile->deferred) could be executed after unmounting, which
will trigger a warning in generic_shutdown_super:
BUG: Dentry 00000000a14a6845{i=c,n=file} still in use (1) [unmount of
cifs cifs]
The detailed processs is:
process A process B kworker
fd = open(PATH)
vfs_open
file->__f_path = *path // dentry->d_lockref.count = 1
cifs_open
cifs_new_fileinfo
cfile->dentry = dget(dentry) // dentry->d_lockref.count = 2
close(fd)
__fput
cifs_close
queue_delayed_work(deferredclose_wq, cfile->deferred)
dput(dentry) // dentry->d_lockref.count = 1
smb2_deferred_work_close
_cifsFileInfo_put
list_del(&cifs_file->flist)
umount
cleanup_mnt
deactivate_super
cifs_kill_sb
cifs_close_all_deferred_files_sb
cifs_close_all_deferred_files
// cannot find cfile, skip _cifsFileInfo_put
kill_anon_super
generic_shutdown_super
shrink_dcache_for_umount
umount_check
WARN ! // dentry->d_lockref.count = 1
cifsFileInfo_put_final
dput(cifs_file->dentry)
// dentry->d_lockref.count = 0
Fix it by flushing 'deferredclose_wq' before calling kill_anon_super.
Fetch a reproducer in https://bugzilla.kernel.org/show_bug.cgi?id=221548.
📍 영향받는 시스템
Linux kernel (CIFS module 사용 시스템)
⚔️ 공격 벡터
로컬 사용자가 CIFS 파일 시스템을 마운트하고 특정 순서로 파일을 열고 닫은 뒤 마운트를 해제하는 방식으로 유도 가능
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 'deferredclose_wq' 플러시 로직을 적용해야 함
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인