🇰🇷 한글 설명
Linux 커널의 media: mtk-jpeg 드라이버에서 작업 취소 없이 컨텍스트 구조체를 해제하여 발생하는 Use-After-Free 취약점입니다. 장치 종료 시 실행 중인 작업이 남아 있으면 해제된 메모리에 접근하여 시스템 불안정이나 권한 상승을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터가 작업을 수행하던 중 갑자기 해당 작업에 필요한 메모리를 지워버려서, 남은 작업이 빈 공간을 건드리며 오류를 일으키는 문제입니다. 이로 인해 시스템이 멈추거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
media: mtk-jpeg: fix use-after-free in release path due to uncancelled work
The mtk_jpeg_release() function frees the context structure (ctx) without
first cancelling any pending or running work in ctx->jpeg_work. This
creates a race window where the workqueue callback may still be accessing
the context memory after it has been freed.
Race condition:
CPU 0 (release) CPU 1 (workqueue)
---------------- ------------------
close()
mtk_jpeg_release()
mtk_jpegenc_worker()
ctx = work->data
// accessing ctx
kfree(ctx) // freed!
access ctx // UAF!
The work is queued via queue_work() during JPEG encode/decode operations
(via mtk_jpeg_device_run). If the device is closed while work is pending
or running, the work handler will access freed memory.
Fix this by calling cancel_work_sync() BEFORE acquiring the mutex. This
ordering is critical: if cancel_work_sync() is called after mutex_lock(),
and the work handler also tries to acquire the same mutex, it would cause
a deadlock.
Note: The open error path does NOT need cancel_work_sync() because
INIT_WORK() only initializes the work structure - it does not schedule
it. Work is only scheduled later during ioctl operations.
📍 영향받는 시스템
Linux kernel (media: mtk-jpeg driver components)
⚔️ 공격 벡터
장치 종료(close) 시점에 의도적으로 경합 상태(Race Condition)를 유도하여 해제된 메모리에 접근
🛡️ 대응 방법
mtk_jpeg_release() 함수 내에서 mutex 획득 전 cancel_work_sync()를 호출하도록 커널 패치 적용
🔧 검증 코드
커널 버전과 해당 드라이버 소스 코드 내에 취약점이 수정된 함수 호출 로직이 포함되어 있는지 확인합니다.
uname -a && grep -r 'mtk_jpeg_release' /lib/modules/$(uname -r)/kernel/drivers/media/ 2>/dev/null