🇰🇷 한글 설명
Linux 커널 libata 서브시스템에서, 지연된 QC(deferred_qc)를 해제할 때 예약된 작업(work)을 취소하지 않아 발생하는 문제입니다. 이로 인해 포트 리셋 이후 잘못된 명령이 실행되어 커널 경고(WARN_ON)가 발생할 수 있습니다.
💡 쉬운 설명
디스크 컨트롤러가 명령을 처리하는 과정에서 예약된 작업이 취소되지 않아, 엉뚱한 시점에 실행되는 문제입니다. 이로 인해 시스템에 경고가 발생하거나 불안정해질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ata: libata: cancel pending work after clearing deferred_qc
Syzbot reported a WARN_ON() in ata_scsi_deferred_qc_work(), caused by
ap->ops->qc_defer() returning non-zero before issuing the deferred qc.
ata_scsi_schedule_deferred_qc() is called during each command completion.
This function will check if there is a deferred QC, and if
ap->ops->qc_defer() returns zero, meaning that it is possible to queue the
deferred qc at this time (without being deferred), then it will queue the
work which will issue the deferred qc.
Once the work get to run, which can potentially be a very long time after
the work was scheduled, there is a WARN_ON() if ap->ops->qc_defer() returns
non-zero.
While we hold the ap->lock both when assigning and clearing deferred_qc,
and the work itself holds the ap->lock, the code currently does not cancel
the work after clearing the deferred qc.
This means that the following scenario can happen:
1) One or several NCQ commands are queued.
2) A non-NCQ command is queued, gets stored in ap->deferred_qc.
3) Last NCQ command gets completed, work is queued to issue the deferred
qc.
4) Timeout or error happens, ap->deferred_qc is cleared. The queued work is
currently NOT canceled.
5) Port is reset.
6) One or several NCQ commands are queued.
7) A non-NCQ command is queued, gets stored in ap->deferred_qc.
8) Work is finally run. Yet at this time, there is still NCQ commands in
flight.
The work in 8) really belongs to the non-NCQ command in 2), not to the
non-NCQ command in 7). The reason why the work is executed when it is not
supposed to, is because it was never canceled when ap->deferred_qc was
cleared in 4). Thus, ensure that we always cancel the work after clearing
ap->deferred_qc.
Another potential fix would have been to let ata_scsi_deferred_qc_work() do
nothing if ap->ops->qc_defer() returns non-zero. However, canceling the
work when clearing ap->deferred_qc seems slightly more logical, as we hold
the ap->lock when clearing ap->deferred_qc, so we know that the work cannot
be holding the lock. (The function could be waiting for the lock, but that
is okay since it will do nothing if ap->deferred_qc is not set.)
📍 영향받는 시스템
패치 이전의 Linux 커널 (libata 서브시스템을 사용하는 SATA/AHCI 디스크 환경)
⚔️ 공격 벡터
로컬 사용자가 디스크 명령 오류나 타임아웃을 유발하여 잘못된 작업 실행 상태를 만드는 방식으로, 주로 서비스 거부(커널 경고/불안정)를 유발할 수 있습니다.
🛡️ 대응 방법
배포판에서 제공하는 보안 업데이트된 Linux 커널로 업그레이드하고 재부팅합니다.
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지에서 이 CVE의 수정 버전과 비교하여, 같거나 높으면 패치된 것이고 낮으면 업데이트가 필요합니다.