🇰🇷 한글 설명
Linux 커널의 nitro_enclaves 구성 요소에서 SLOT_ALLOC 요청 실패 시 발생하는 Use-After-Free 취약점입니다. 오류 처리 과정에서 enclave_file이 해제되기 전 ne_enclave 객체가 먼저 해제되어, 이후 ne_enclave_release() 함수가 이미 해제된 메모리에 접근하여 발생합니다.
💡 쉬운 설명
프로그램이 작업을 하다가 오류가 발생했을 때, 이미 버려진 메모리 공간을 다시 사용하려고 시도하면서 발생하는 문제입니다. 이로 인해 시스템이 불안정해지거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nitro_enclaves: fix use-after-free on SLOT_ALLOC failure
When ne_create_vm_ioctl() fails the SLOT_ALLOC request after
anon_inode_getfile() has succeeded, the error path calls
fput(enclave_file) and then frees ne_enclave.
In normal userspace context, fput() defers the final __fput() via
task_work. ne_enclave_release() therefore runs after ne_enclave has
already been freed and dereferences ne_enclave->slot_uid, causing a
use-after-free: KASAN: slab-use-after-free in ne_enclave_release.
The enclave has no slot allocated and is not yet linked into the
enclaves list on this error path, so ne_enclave_release() is expected
to return early when slot_uid is zero. However, reading slot_uid
already accesses the freed object.
Clear enclave_file->private_data before fput() on the error path.
ne_enclave_release() then returns immediately when private_data is
NULL, leaving the ioctl error path as the sole owner of ne_enclave.
This is safe because the file has not been fd_install()'d yet.
Tested on an AWS EC2 m5.2xlarge with CONFIG_KASAN=y. Without the
patch, the reproducer triggers a KASAN slab-use-after-free on every
SLOT_ALLOC failure. With the patch, no KASAN report is produced and
the SLOT_ALLOC error is still returned. Normal enclave creation and
teardown are unaffected.
📍 영향받는 시스템
Linux kernel (nitro_enclaves 모듈을 사용하는 환경)
⚔️ 공격 벡터
특수하게 조작된 ioctl 요청을 통해 SLOT_ALLOC 실패를 유도하여 메모리 오류 발생
🛡️ 대응 방법
커널 패치를 적용하여 오류 경로에서 fput() 호출 전 enclave_file->private_data를 NULL로 초기화
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전인지 확인