🇰🇷 한글 설명
Linux 커널에서 nullfs 디렉터리는 변경되지 않는 디렉터리임에도 iterate_dir()가 i_rwsem 잠금을 getdents() 실행 동안 유지합니다. 이로 인해 서로 무관한 사용자 간에 잠금 대기가 발생해 서비스 지연이 생길 수 있으며, 이를 해결하기 위해 FOP_IMMUTABLE 플래그를 도입해 해당 디렉터리에서는 잠금을 생략하도록 수정되었습니다.
💡 쉬운 설명
리눅스 커널에서 변경되지 않는 특정 디렉터리를 읽을 때 불필요하게 잠금을 걸어, 다른 사용자가 같은 디렉터리를 쓰려 할 때 오래 기다리게 되는 문제입니다. 이 문제는 보안 침해보다는 성능 저하와 서비스 지연에 가깝습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
readdir: take no inode lock on an immutable directory
iterate_dir() takes the directory's i_rwsem shared and holds it across
->iterate_shared(). For a directory that never has an entry and is
never removed the lock keeps nothing still, it only orders every reader
and every writer of that inode behind each other.
For the directory of a nullfs instance that matters. The instance of
the initial mount namespace is the root of every empty mount namespace
and the private instance is the root of every kernel thread, so one
inode is shared across users who have nothing else in common. And a
reader can hold the lock for as long as it likes: back the getdents()
buffer with a mapping of a file on a FUSE mount of your own, let the
copy of "." and ".." fault and let the server wait. Queue an exclusive
taker behind it, a mkdir() in that directory goes through start_dirop()
before the read-only mount is reported, and from then on every lookup
that misses the dcache in that directory, every create and every mount
on it waits until the server answers. One user of an empty mount
namespace stalls all the others.
Add FOP_IMMUTABLE for the file operations of a directory that never
changes and is never removed and let iterate_dir() skip the lock for
it. The flag never changes for a file, ->f_pos is protected by
f_pos_lock since directories are FMODE_ATOMIC_POS, IS_DEADDIR can't be
set on such a directory and neither touch_atime() nor fsnotify take
i_rwsem. Set it on the nullfs directory. The placeholder directories of
libfs never have an entry either but their owners remove them, so they
keep the lock.
📍 영향받는 시스템
수정 전 Linux 커널 (nullfs 디렉터리를 사용하는 환경, CVSS 점수 미부여)
⚔️ 공격 벡터
로컬 사용자가 FUSE 마운트를 이용해 getdents() 버퍼 페이지 폴트를 장기간 지연시켜 공유 디렉터리 잠금을 점유하면 다른 사용자의 조회·생성 작업이 지연됩니다.
🛡️ 대응 방법
수정이 포함된 최신 Linux 커널 버전으로 업데이트하고 배포판의 보안 권고를 적용하십시오.
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지 또는 커널 패치 적용 여부와 대조해 수정 포함 버전인지 확인하며, 패치된 커널이면 이 취약점에 영향을 받지 않습니다.