🇰🇷 한글 설명
Linux 커널의 nfsd 구성 요소에서 RCU(Read-Copy-Update) 보호 없이 cmpxchg를 사용하여 발생하는 레이스 컨디션 취약점입니다. nfsd_file 객체가 해제된 후 메모리가 재사용되는 과정에서 적절한 잠금 메커니즘이 없어 잘못된 메모리 참조가 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터가 데이터를 읽고 쓰는 과정에서 순서가 어긋나, 이미 삭제된 데이터 영역을 마치 살아있는 데이터인 것처럼 착각하여 접근하는 문제입니다. 이로 인해 시스템이 충돌하거나 보안상 위험한 동작이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nfsd: hold rcu across localio cmpxchg retry
nfsd_file objects are freed via call_rcu (filecache.c:296), and
nfsd_file_slab is created without SLAB_TYPESAFE_BY_RCU
(KMEM_CACHE(nfsd_file, 0) at filecache.c:789), so the slab page
backing a freed nfsd_file becomes freely reclaimable once the RCU
grace period elapses.
The again: retry block in nfsd_open_local_fh() loads a pointer with
cmpxchg and then calls nfsd_file_get(new) (which is
refcount_inc_not_zero) without holding rcu_read_lock. The sole caller
nfs_open_local_fh() drops rcu_read_lock before invoking this helper,
so no outer reader-side critical section covers the load.
CPU 0 (nfsd_open_local_fh) CPU 1 (nfsd_file_put_local)
----- -----
new = cmpxchg(pnf, NULL, ...)
nf = xchg(pnf, NULL)
nfsd_file_put(nf)
last ref -> call_rcu()
/* grace period elapses;
slab page recycled */
nfsd_file_get(new)
refcount_inc_not_zero(&new->nf_ref)
/* operates on recycled memory */
A non-zero word at the nf_ref offset of the recycled object makes the
refcount bump appear to succeed, and the caller then dereferences
new->nf_net and new->nf_file out of freed memory.
Fix by taking rcu_read_lock() immediately before the cmpxchg and
releasing it on all three exits of the if (new) block: the goto-again
retry, the lost-race cleanup path, and the install-succeeded path.
nfsd_file_put() and nfsd_net_put() stay outside the RCU section so
they remain free to block.
📍 영향받는 시스템
Linux Kernel (nfsd 모듈 사용 환경)
⚔️ 공격 벡터
NFS 서버의 로컬 파일 핸들링 과정에서 특정 타이밍에 정밀하게 설계된 요청을 보내 메모리 레이스 컨디션 유도
🛡️ 대응 방법
커널 패치를 적용하여 nfsd_open_local_fh 함수 내 cmpxchg 호출 전후로 rcu_read_lock()을 적용한 최신 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이상인지 확인