🇰🇷 한글 설명
Linux 커널의 nfsd 구성 요소에서 setlease 실패 시 layout stateid를 적절히 제거하지 않아 발생하는 취약점입니다. 이로 인해 IDR 슬롯이 해제된 슬랩 메모리를 가리키는 대기 포인터(dangling pointer)가 남게 되어, 이후 IDR 탐색 시 메모리 오류를 유발할 수 있습니다.
💡 쉬운 설명
데이터를 관리하는 목록에서 항목을 지울 때, 실제 데이터만 지우고 목록에서는 지우지 않아 발생하는 오류입니다. 이로 인해 시스템이 이미 사라진 데이터를 참조하려다 충돌하거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nfsd: release layout stid on setlease failure
nfs4_alloc_stid() publishes the new stid into cl->cl_stateids via
idr_alloc_cyclic() under cl_lock before returning to
nfsd4_alloc_layout_stateid(). When nfsd4_layout_setlease() then
fails, the error path frees the layout stateid directly with
kmem_cache_free() without ever calling idr_remove(), leaving the
IDR slot pointing at freed slab memory. Any subsequent IDR walker
(states_show, client teardown) dereferences the dangling pointer.
The correct teardown for an IDR-published stid is nfs4_put_stid(),
which removes the IDR slot under cl_lock, dispatches sc_free
(nfsd4_free_layout_stateid) to release ls->ls_file via
nfsd4_close_layout(), and drops the nfs4_file reference in its
tail.
A second issue blocks that switch: nfsd4_free_layout_stateid()
unconditionally inspects ls->ls_fence_work via
delayed_work_pending() under ls_lock, but
INIT_DELAYED_WORK(&ls->ls_fence_work, ...) currently runs only
after the setlease call. On the setlease-failure path the
destructor would touch an uninitialized delayed_work.
nfsd4_alloc_layout_stateid()
nfs4_alloc_stid() /* idr_alloc_cyclic under cl_lock */
nfsd4_layout_setlease() /* fails */
nfs4_put_stid()
nfsd4_free_layout_stateid()
delayed_work_pending(&ls->ls_fence_work) /* needs INIT */
nfsd4_close_layout() /* nfsd_file_put(ls->ls_file) */
put_nfs4_file()
Fix by hoisting the ls_fenced / ls_fence_delay / INIT_DELAYED_WORK
initialization above the nfsd4_layout_setlease() call, and replace
the manual nfsd_file_put + put_nfs4_file + kmem_cache_free cleanup
with a single nfs4_put_stid(stp).
📍 영향받는 시스템
Linux Kernel (nfsd module 사용 환경)
⚔️ 공격 벡터
NFSv4 레이아웃 설정 과정에서 의도적으로 setlease 실패를 유도하여 메모리 손상 유발
🛡️ 대응 방법
커널 패치를 적용하여 nfsd4_layout_setlease 호출 전 초기화 과정을 개선하고 nfs4_put_stid()를 사용하도록 수정
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 보안 패치 버전인지 확인