🇰🇷 한글 설명
Linux 커널의 NFC NCI 드라이버에서 nci_data_exchange_complete 함수 호출 시 발생하는 레이스 컨디션 취약점입니다. nci_close_device와 nci_rx_work가 동시에 실행될 때 콜백 함수가 중복 호출되어 소켓 참조 횟수(refcount)가 언더플로우되고, 사용 중인 소켓이 해제될 수 있습니다.
💡 쉬운 설명
NFC 기능을 사용할 때 두 가지 작업이 동시에 일어나면서 시스템이 소켓을 실수로 두 번 닫아버리는 문제입니다. 이로 인해 사용 중인 데이터 통로가 갑자기 끊기거나 시스템 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nfc: nci: fix double completion race in nci_data_exchange_complete
nci_close_device() and nci_rx_work can both call
nci_data_exchange_complete() concurrently. After commit 4527025d440ce8
("nfc: nci: fix circular locking dependency in nci_close_device") moved
flush_workqueue(ndev->rx_wq) after mutex_unlock(&ndev->req_lock),
rx_work is no longer serialized with the explicit completion call in the
close path. Both callers read the non-NULL callback pointer and invoke
rawsock_data_exchange_complete(), which calls sock_put() -- but only one
sock_hold() was taken, so the second sock_put() underflows the refcount
and frees the socket while it is still in use.
Replace the bare clear_bit(NCI_DATA_EXCHANGE) with
test_and_clear_bit() so that only the first caller proceeds to invoke
the callback.
📍 영향받는 시스템
NFC NCI 드라이버를 사용하는 Linux 커널 버전
⚔️ 공격 벡터
로컬 공격자가 특정 NFC 작업 시퀀스를 유도하여 커널 메모리 오류 및 소켓 해제 유도
🛡️ 대응 방법
커널 패치를 적용하여 clear_bit 대신 원자적 연산인 test_and_clear_bit를 사용하도록 업데이트
🔧 검증 코드
출력된 커널 버전이 취약점이 수정된 최신 패치 버전인지 확인