🇰🇷 한글 설명
Linux 커널의 ksmbd 모듈에서 SMB2 잠금 요청 처리 중 경합 조건으로 인해 Use-After-Free 및 Double-Free 취약점이 발생합니다. 잠금 요청 배열 처리 중 오류가 발생하여 롤백을 수행할 때, 이미 공개된 잠금 객체를 다른 스레드가 해제하면 메모리 오류가 발생할 수 있습니다.
💡 쉬운 설명
파일 잠금 기능을 처리하는 과정에서 작업이 중간에 실패했을 때, 이미 처리된 내용을 되돌리려다 이미 삭제된 메모리에 다시 접근하여 시스템 오류를 일으키는 문제입니다. 이로 인해 시스템이 충돌하거나 보안 공격에 악용될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: defer publishing granted locks to prevent UAF/double-free race
In smb2_lock(), mid-batch granted locks are published to connection-wide
(conn->lock_list) and file-wide (fp->lock_list) lists immediately upon
vfs_lock_file() success, while also remaining tracked on the stack-local
rollback_list.
If a subsequent element in the same SMB2_LOCK request array fails
validation or execution, the thread jumps to out: and walks
rollback_list to undo previously granted locks. However, because the
granted lock was already published to conn->lock_list, a concurrent
UNLOCK request on the same connection can find the lock object and
kfree() it before the rollback loop executes.
When the granting thread subsequently walks rollback_list, it
dereferences and frees the already-freed ksmbd_lock structure, resulting
in a Use-After-Free and Double-Free (on both ksmbd_lock and struct
file_lock).
Fix this by deferring the publication of granted locks to
conn->lock_list and fp->lock_list until after the entire array of lock
elements has been processed without error. Mid-batch grants remain
tracked exclusively on the request-local rollback_list until the whole
batch succeeds, eliminating the race window.
📍 영향받는 시스템
Linux kernel (ksmbd module 포함 버전)
⚔️ 공격 벡터
동시에 SMB2 잠금 및 해제 요청을 보내 경합 조건을 유발하여 메모리 오류 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 ksmbd의 잠금 게시 지연 로직 적용
🔧 검증 코드
출력된 커널 버전이 ksmbd 취약점이 수정된 최신 패치 버전인지 확인