🇰🇷 한글 설명
Linux 커널의 libata-scsi 구성 요소에서 NCQ(Native Command Queuing) 명령이 지속적으로 실행될 때 비-NCQ 명령이 실행되지 못하고 무한히 지연되는 명령 기아(Starvation) 현상이 발생할 수 있습니다. 이 취약점은 다중 제출 큐를 사용하는 호스트 어댑터에서 특정 명령이 계속해서 뒤로 밀려나 시스템 성능 저하나 명령 실행 불능 상태를 초래할 수 있습니다.
💡 쉬운 설명
컴퓨터 저장 장치에 명령을 내릴 때, 특정 종류의 명령들이 너무 빠르게 계속 들어오면 다른 종류의 명령이 차례를 받지 못하고 계속 기다리기만 하는 문제가 있습니다. 이로 인해 시스템이 명령을 처리하지 못하고 멈춘 것처럼 보일 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ata: libata-scsi: avoid Non-NCQ command starvation
When a non-NCQ command is issued while NCQ commands are being executed,
ata_scsi_qc_issue() indicates to the SCSI layer that the command issuing
should be deferred by returning SCSI_MLQUEUE_XXX_BUSY. This command
deferring is correct and as mandated by the ACS specifications since
NCQ and non-NCQ commands cannot be mixed.
However, in the case of a host adapter using multiple submission queues,
when the target device is under a constant load of NCQ commands, there
are no guarantees that requeueing the non-NCQ command will be executed
later and it may be deferred again repeatedly as other submission queues
can constantly issue NCQ commands from different CPUs ahead of the
non-NCQ command. This can lead to very long delays for the execution of
non-NCQ commands, and even complete starvation for these commands in the
worst case scenario.
Since the block layer and the SCSI layer do not distinguish between
queueable (NCQ) and non queueable (non-NCQ) commands, libata-scsi SAT
implementation must ensure forward progress for non-NCQ commands in the
presence of NCQ command traffic. This is similar to what SAS HBAs with a
hardware/firmware based SAT implementation do.
Implement such forward progress guarantee by limiting requeueing of
non-NCQ commands from ata_scsi_qc_issue(): when a non-NCQ command is
received and NCQ commands are in-flight, do not force a requeue of the
non-NCQ command by returning SCSI_MLQUEUE_XXX_BUSY and instead return 0
to indicate that the command was accepted but hold on to the qc using
the new deferred_qc field of struct ata_port.
This deferred qc will be issued using the work item deferred_qc_work
running the function ata_scsi_deferred_qc_work() once all in-flight
commands complete, which is checked with the port qc_defer() callback
return value indicating that no further delay is necessary. This check
is done using the helper function ata_scsi_schedule_deferred_qc() which
is called from ata_scsi_qc_complete(). This thus excludes this mechanism
from all internal non-NCQ commands issued by ATA EH.
When a port deferred_qc is non NULL, that is, the port has a command
waiting for the device queue to drain, the issuing of all incoming
commands (both NCQ and non-NCQ) is deferred using the regular busy
mechanism. This simplifies the code and also avoids potential denial of
service problems if a user issues too many non-NCQ commands.
Finally, whenever ata EH is scheduled, regardless of the reason, a
deferred qc is always requeued so that it can be retried once EH
completes. This is done by calling the function
ata_scsi_requeue_deferred_qc() from ata_eh_set_pending(). This avoids
the need for any special processing for the deferred qc in case of NCQ
error, link or device reset, or device timeout.
📍 영향받는 시스템
Linux kernel (ata: libata-scsi 관련 모듈 사용 시스템)
⚔️ 공격 벡터
지속적인 NCQ 명령 부하를 유발하여 비-NCQ 명령의 실행을 방해하는 서비스 거부(DoS) 형태의 공격
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 deferred_qc 메커니즘이 적용된 libata-scsi 패치를 적용해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인합니다.