🇰🇷 한글 설명
Linux 커널의 rbd 모듈에서 unmap 과정 중 lock_dwork를 비우는 과정에 레이스 컨디션(Race Condition) 취약점이 발견되었습니다. 이로 인해 rbd_dev_image_unlock() 이후에도 독점 잠금 작업이 다시 큐에 추가될 수 있으며, 이는 이미 해제된 리소스에 접근하여 시스템 오류나 커널 패닉을 유발할 수 있습니다.
💡 쉬운 설명
데이터 저장 장치를 해제하는 과정에서 시스템이 미처 정리하지 못한 작업이 뒤늦게 실행되어 충돌이 발생하는 문제입니다. 이로 인해 컴퓨터 시스템이 갑자기 멈추거나 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
rbd: eliminate a race in lock_dwork draining on unmap
Given how rbd_lock_add_request() and rbd_img_exclusive_lock() are
written, lock_dwork may be (re)queued more than it's actually needed:
for example in case a new I/O request comes in while we are in the
middle of rbd_acquire_lock() on behalf of another I/O request. This is
expected and with rbd_release_lock() preemptively canceling lock_dwork
is benign under normal operation.
A more problematic example is maybe_kick_acquire():
if (have_requests || delayed_work_pending(&rbd_dev->lock_dwork)) {
dout("%s rbd_dev %p kicking lock_dwork\n", __func__, rbd_dev);
mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, 0);
}
It's not unrealistic for lock_dwork to get canceled right after
delayed_work_pending() returns true and for mod_delayed_work() to
requeue it right there anyway. This is a classic TOCTOU race.
When it comes to unmapping the image, there is an implicit assumption
of no self-initiated exclusive lock activity past the point of return
from rbd_dev_image_unlock() which unlocks the lock if it happens to be
held. This unlock is assumed to be final and lock_dwork (as well as
all other exclusive lock tasks, really) isn't expected to get queued
again. However, lock_dwork is canceled only in cancel_tasks_sync()
(i.e. later in the unmap sequence) and on top of that the cancellation
can get in effect nullified by maybe_kick_acquire(). This may result
in rbd_acquire_lock() executing after rbd_dev_device_release() and
rbd_dev_image_release() run and free and/or reset a bunch of things.
One of the possible failure modes then is a violated
rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
in rbd_dev_header_info() which is called via rbd_dev_refresh() from
rbd_post_acquire_action().
Redo exclusive lock task draining to provide saner semantics and try
to meet the assumptions around rbd_dev_image_unlock().
📍 영향받는 시스템
Linux Kernel (rbd 모듈 사용 환경)
⚔️ 공격 벡터
로컬 공격자가 특정 I/O 요청과 unmap 작업을 정밀하게 타이밍을 맞춰 실행하여 레이스 컨디션을 유발
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 rbd 독점 잠금 작업 처리 로직을 수정해야 함
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이상인지 확인