🇰🇷 한글 설명
리눅스 커널의 USB FunctionFS 드라이버에서 발생하는 Use-After-Free 취약점입니다. 구성 전환 시 ffs_func_eps_disable 함수와 사용자 공간의 ffs_epfile_release 함수가 동시에 호출될 때 레이스 컨디션이 발생하여 이미 해제된 메모리 영역에 접근할 수 있습니다.
💡 쉬운 설명
컴퓨터가 데이터를 처리하는 도중에 다른 명령이 동시에 들어와서, 이미 삭제된 메모리 주소를 다시 사용하려고 시도할 때 발생하는 오류입니다. 이로 인해 시스템이 충돌하거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
usb: f_fs: Fix use-after-free for epfile
Consider a case where ffs_func_eps_disable is called from
ffs_func_disable as part of composition switch and at the
same time ffs_epfile_release get called from userspace.
ffs_epfile_release will free up the read buffer and call
ffs_data_closed which in turn destroys ffs->epfiles and
mark it as NULL. While this was happening the driver has
already initialized the local epfile in ffs_func_eps_disable
which is now freed and waiting to acquire the spinlock. Once
spinlock is acquired the driver proceeds with the stale value
of epfile and tries to free the already freed read buffer
causing use-after-free.
Following is the illustration of the race:
CPU1 CPU2
ffs_func_eps_disable
epfiles (local copy)
ffs_epfile_release
ffs_data_closed
if (last file closed)
ffs_data_reset
ffs_data_clear
ffs_epfiles_destroy
spin_lock
dereference epfiles
Fix this races by taking epfiles local copy & assigning it under
spinlock and if epfiles(local) is null then update it in ffs->epfiles
then finally destroy it.
Extending the scope further from the race, protecting the ep related
structures, and concurrent accesses.
📍 영향받는 시스템
Linux Kernel (USB FunctionFS driver components)
⚔️ 공격 벡터
사용자 공간에서 특정 USB 관련 시스템 호출을 통해 커널 드라이버의 레이스 컨디션을 유도하여 발생
🛡️ 대응 방법
리눅스 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 epfile 구조체 접근 시 스핀락 보호를 강화해야 함
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전 이상인지 확인합니다.