🇰🇷 한글 설명
Linux 커널의 OP-TEE 드라이버에서 optee_probe() 도중 TEE 장치가 struct optee의 초기화가 끝나기 전에 등록되어, 사용자 공간과 커널 공간에서 열린 컨텍스트가 초기화되지 않은 뮤텍스와 NULL 포인터에 접근할 수 있는 문제입니다. 수정은 tee_device_register() 호출을 구조체 초기화 완료 이후로 옮기는 것입니다.
💡 쉬운 설명
장치가 아직 완전히 준비되지 않은 상태에서 외부에 공개되어, 그 짧은 틈에 프로그램이 접근하면 시스템이 오작동할 수 있습니다. 준비가 끝난 뒤에만 장치를 열어주도록 순서를 바로잡은 것입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
optee: register TEE devices only once fully initialized
optee_probe() called tee_device_register() on both the client and the
supplicant device before the rest of struct optee had been initialized.
tee_device_register() calls cdev_device_add(), which does two things at
once: it creates /dev/tee0 and /dev/teepriv0, and it links the device
into the tee class so that class_find_device() can find it. From that
moment on the device is reachable both from user space via tee_open()
and from kernel space via tee_client_open_context(). The only gate in
teedev_open() is tee_device_get(), which merely checks that
teedev->desc is non-NULL, which was already set by tee_device_alloc().
Therefore, there is effectively no gate at all.
A context opened in that window can run against a struct optee where
- optee->call_queue.mutex is not initialized by optee_cq_init()
- optee->supp mutex and completions is not initialized by
optee_supp_init()
- optee->rpmb_dev_mutex is not initialized yet,
- the message argument cache is not initialized by
optee_shm_arg_cache_init()
- optee->ctx is still NULL
Any open session or invoke during this window takes uninitialized
mutexes and dereferences a NULL pointer.
Fix it by moving both tee_device_register() calls down to the point
where all of struct optee is set up.
[JW: adding fixes and cc]
📍 영향받는 시스템
패치 전 Linux 커널의 OP-TEE 드라이버(drivers/tee/optee) 사용 시스템 (정확한 영향 버전은 CVE 공지 확인 필요)
⚔️ 공격 벡터
로컬 사용자가 장치 등록과 초기화 사이의 시간 창에서 /dev/tee0을 열고 세션이나 invoke를 실행하여 메모리 손상이나 커널 크래시를 유발
🛡️ 대응 방법
커널을 tee_device_register()가 구조체 초기화 완료 후 호출되도록 수정한 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전을 배포판의 보안 공지 또는 커널 changelog와 대조하여 해당 수정이 포함된 버전인지 확인하고, 미포함이면 업데이트가 필요합니다.