🇰🇷 한글 설명
Linux 커널의 Greybus 서브시스템에서 disconnect 호출 이후 write 작업이 수행될 경우 발생하는 Use-After-Free 취약점입니다. 연결이 해제되어 객체가 메모리에서 해제되었음에도 불구하고 해당 객체에 접근을 시도하여 커널 패닉(NULL pointer dereference)을 유발합니다.
💡 쉬운 설명
장치가 연결 해제된 상태에서 데이터를 쓰려고 할 때, 이미 사라진 정보를 참조하여 컴퓨터 시스템이 갑자기 멈추거나 오류가 발생하는 문제입니다. 이를 방지하기 위해 데이터 쓰기와 연결 해제 작업이 동시에 일어나지 않도록 잠금 장치를 추가해야 합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
greybus: raw: fix use-after-free if write is called after disconnect
If a user writes to the chardev after disconnect has been called, the
kernel panics with the following trace (with
CONFIG_INIT_ON_FREE_DEFAULT_ON=y):
BUG: kernel NULL pointer dereference, address: 0000000000000218
...
Call Trace:
<TASK>
gb_operation_create_common+0x61/0x180
gb_operation_create_flags+0x28/0xa0
gb_operation_sync_timeout+0x6f/0x100
raw_write+0x7b/0xc7 [gb_raw]
vfs_write+0xcf/0x420
? task_mm_cid_work+0x136/0x220
ksys_write+0x63/0xe0
do_syscall_64+0xa4/0x290
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Disconnect calls gb_connection_destroy, which ends up freeing the
connection object. When gb_operation_sync is called in the write file
operations, its gets a freed connection as parameter and the kernel
panics.
The gb_connection_destroy cannot be moved out of the disconnect
function, as the Greybus subsystem expect all connections belonging to a
bundle to be destroyed when disconnect returns.
To prevent this bug, use a rw lock to synchronize access between write
and disconnect. This guarantees that the write function doesn't try
to use a disconnected connection.
📍 영향받는 시스템
Greybus 서브시스템을 사용하는 Linux 커널 버전
⚔️ 공격 벡터
장치 연결 해제 시점과 데이터 쓰기 요청 시점을 교묘하게 맞추는 타이밍 공격(Race Condition)
🛡️ 대응 방법
커널 패치가 적용된 최신 버전의 Linux 커널로 업데이트하거나, rw lock을 통해 동기화가 적용된 패치를 적용해야 합니다.
🔧 검증 코드
출력된 커널 버전이 Greybus Use-After-Free 취약점이 해결된 패치 버전인지 확인합니다.