🇰🇷 한글 설명
Linux 커널의 functionfs에서 파일 오픈과 제거 작업 간의 경쟁 상태(Race Condition)로 인해 발생하는 Use-After-Free(UAF) 취약점입니다. ffs_epfile_open() 함수가 실행되는 동안 파일이 제거되면, 파일 객체가 이미 해제된 메모리 주소를 가리키게 되어 시스템 불안정이나 권한 상승을 초래할 수 있습니다.
💡 쉬운 설명
파일을 여는 동작과 삭제하는 동작이 동시에 일어날 때, 이미 삭제된 파일을 계속 사용하려고 시도하여 발생하는 오류입니다. 이로 인해 컴퓨터 시스템이 갑자기 멈추거나 해커가 시스템 제어권을 얻을 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
functionfs: fix the open/removal races
ffs_epfile_open() can race with removal, ending up with file->private_data
pointing to freed object.
There is a total count of opened files on functionfs (both ep0 and
dynamic ones) and when it hits zero, dynamic files get removed.
Unfortunately, that removal can happen while another thread is
in ffs_epfile_open(), but has not incremented the count yet.
In that case open will succeed, leaving us with UAF on any subsequent
read() or write().
The root cause is that ffs->opened is misused; atomic_dec_and_test() vs.
atomic_add_return() is not a good idea, when object remains visible all
along.
To untangle that
* serialize openers on ffs->mutex (both for ep0 and for dynamic files)
* have dynamic ones use atomic_inc_not_zero() and fail if we had
zero ->opened; in that case the file we are opening is doomed.
* have the inodes of dynamic files marked on removal (from the
callback of simple_recursive_removal()) - clear ->i_private there.
* have open of dynamic ones verify they hadn't been already removed,
along with checking that state is FFS_ACTIVE.
📍 영향받는 시스템
functionfs를 사용하는 Linux 커널 버전
⚔️ 공격 벡터
특수하게 조작된 멀티스레드 환경에서 functionfs 파일 오픈과 제거를 동시에 수행하여 메모리 오류 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인