🇰🇷 한글 설명
Linux 커널의 9p 네트워크 프로토콜에서 RDMA 상태를 관리하는 과정 중 레이스 컨디션(경쟁 상태) 취약점이 발견되었습니다. recv_done() 및 p9_cm_event_handler() 함수가 req_lock 없이 rdma->state를 수정하여 상태 전이가 누락되거나 연결 상태 머신이 손상될 수 있습니다. 이로 인해 연결 해제 과정에서 RDMA 요청 객체에 대한 Use-After-Free 오류가 발생할 수 있습니다.
💡 쉬운 설명
여러 작업이 동시에 네트워크 연결 상태를 바꾸려고 할 때, 서로 충돌하여 데이터가 꼬이는 문제입니다. 이 충돌로 인해 시스템이 잘못된 메모리 영역을 참조하게 되어 프로그램이 강제 종료되거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net/9p: fix race condition on rdma->state in trans_rdma.c
The rdma->state field is modified without holding req_lock in both
recv_done() and p9_cm_event_handler(), while rdma_request() accesses
the same field under the req_lock spinlock. This inconsistent locking
creates a race condition:
- recv_done() running in softirq completion context sets
rdma->state = P9_RDMA_FLUSHING without acquiring req_lock
- p9_cm_event_handler() modifies rdma->state at multiple points
(ADDR_RESOLVED, ROUTE_RESOLVED, ESTABLISHED, CLOSED) without
req_lock
- rdma_request() uses spin_lock_irqsave(&rdma->req_lock, flags) to
protect the read-modify-write of rdma->state
The race can cause lost state transitions: recv_done() or the CM
event handler could set state to FLUSHING/CLOSED while rdma_request()
is concurrently checking or modifying state under the lock, leading to
the FLUSHING transition being silently overwritten by CLOSING. This
corrupts the connection state machine and can cause use-after-free on
RDMA request objects during teardown.
Fix by adding req_lock protection to all rdma->state modifications in
recv_done() and p9_cm_event_handler(), matching the pattern already
used in rdma_request(). Use spin_lock_irqsave/spin_unlock_irqrestore
in the CM event handler since it can race with recv_done() which runs
in softirq context.
Tested with a kernel module that races two threads (simulating
rdma_request and recv_done/CM handler) on rdma->state with proper
locking: 5.5M+ FLUSHING writes over 27M iterations with 0 lost
transitions.
📍 영향받는 시스템
Linux Kernel (9p RDMA 프로토콜을 사용하는 시스템)
⚔️ 공격 벡터
네트워크 트래픽을 조작하여 특정 타이밍에 RDMA 상태 변경 이벤트를 유도함으로써 레이스 컨디션 유발
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 rdma->state 수정 시 req_lock 보호가 적용되도록 조치
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인