🇰🇷 한글 설명
Linux 커널의 Bluetooth SCO 모듈에서 sco_recv_scodata() 함수가 hcon->sco_data 포인터를 잠금 없이 해제되는 객체에 접근하여 use-after-free(KASAN 검출)가 발생하는 취약점이 수정되었습니다. 수정은 포인터에 실제 참조 카운트를 부여하고 hdev->lock으로 직렬화하는 방식입니다.
💡 쉬운 설명
블루투스 오디오 연결을 처리하는 리눅스 커널 코드에서 이미 해제된 메모리를 다시 사용하는 문제가 있었습니다. 이로 인해 시스템이 충돌하거나 악의적인 코드가 실행될 가능성이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: SCO: serialise sco_conn lifetime against sco_recv_scodata()
sco_recv_scodata() upgrades the weak hcon->sco_data back-pointer to a
strong reference under hdev->lock:
hci_dev_lock(hdev);
hcon = hci_conn_hash_lookup_handle(hdev, handle);
...
conn = sco_conn_hold_unless_zero(hcon->sco_data);
hci_dev_unlock(hdev);
but the pointer is cleared from the other side without that lock. When
the last sco_conn reference is dropped, sco_conn_free() ran
conn->hcon->sco_data = NULL;
with no hdev->lock held, so the RX path could read hcon->sco_data and
call kref_get_unless_zero() on an sco_conn that was concurrently freed:
BUG: KASAN: slab-use-after-free in sco_conn_hold_unless_zero+0xbe/0x160
Write of size 4 by task kworker/u17:0
Workqueue: hci0 hci_rx_work
Call Trace:
sco_conn_hold_unless_zero+0xbe/0x160
sco_recv_scodata+0x13f/0x490
hci_rx_work+0x3af/0x730
kref_get_unless_zero() only guards against a zero refcount, not against
the backing memory already being freed.
Give hcon->sco_data an actual reference on the sco_conn it points to, so
the object cannot be freed while the pointer is still installed, and only
clear and drop it from sco_conn_del(), which runs under hdev->lock (its
callers, sco_connect_cfm() and sco_disconn_cfm(), hold it). The reader in
sco_recv_scodata() also takes hdev->lock, so the store and the read are
now serialised: the RX path either observes NULL or a reference that is
guaranteed to stay valid until it drops its own.
sco_conn_add() no longer hands its kref_init() reference to the caller as
the connection's only reference; that initial reference is the one owned
by hcon->sco_data, and callers get their own via sco_conn_hold().
Because the sco_conn can now outlive the socket (the association keeps it
alive until the link goes down), the hci_conn can no longer be dropped
from sco_conn_free() without regressing socket close: closing a connected
SCO socket must still tear the link down. Move hci_conn ownership to the
socket instead: __sco_chan_add() takes an hci_conn reference and it is
released from sco_chan_del() and sco_sock_destruct(), exactly once. The
sco_conn no longer owns an hci_conn reference, so sco_conn_add() stops
consuming one and sco_connect() drops the hci_connect_sco() reference on
every path; sco_connect_cfm() no longer needs its hci_conn_hold() dance.
📍 영향받는 시스템
패치 이전의 Linux 커널 (블루투스 SCO 기능 포함 버전, 정확한 영향 범위는 커널 배포판 및 버전별 확인 필요)
⚔️ 공격 벡터
인접한 블루투스 장치가 조작된 SCO 데이터 패킷을 전송하여 커널의 RX 경로에서 해제된 메모리를 참조하도록 유도
🛡️ 대응 방법
배포판 제공 최신 커널 업데이트 또는 해당 upstream 커널 커밋을 포함한 버전으로 업그레이드 후 재부팅
🔧 검증 코드
출력된 커널 버전이 배포판의 보안 패치 목록에 있는 수정된 버전 이상인지 확인하고, 블루투스 모듈이 로드되어 있다면 해당 커널이 패치되었는지 벤더 공지로 검증해야 합니다.
uname -r && grep -i bluetooth /proc/modules 2>/dev/null | head -1