🇰🇷 한글 설명
Linux 커널의 qnap-mcu 드라이버에서 명령 타임아웃 발생 시 스택 버퍼가 해제되지 않아 발생하는 취약점입니다. 타임아웃 이후 지연된 데이터가 이미 종료된 스택 프레임에 기록됨으로써 스택 오버플로우 및 메모리 오염을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터가 명령을 기다리다 지쳐 포기했는데, 나중에 도착한 데이터가 이미 사라진 메모리 공간을 억지로 덮어쓰면서 시스템을 망가뜨리는 문제입니다. 이로 인해 시스템이 멈추거나 해커가 악성 코드를 실행할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mfd: qnap-mcu: keep the reply buffer alive past a command timeout
qnap_mcu_exec() publishes an on-stack buffer to the receive path:
unsigned char rx[QNAP_MCU_RX_BUFFER_SIZE];
...
reply->data = rx;
reply->length = length;
and qnap_mcu_receive_buf() writes into it from the serdev receive path,
which runs out of flush_to_ldisc() and is not serialized against
qnap_mcu_exec() at all. bus_lock cannot cover it, because qnap_mcu_exec()
holds that mutex across wait_for_completion_timeout().
On a timeout qnap_mcu_exec() returns with reply->data still pointing at
its own frame. A reply that arrives late, or an unsolicited message from
the MCU, is then written into a stack frame that has been left, corrupting
whatever runs next on that stack. The same applies when qnap_mcu_write()
fails, since that path returns without touching the reply state either.
Move the receive buffer into struct qnap_mcu. It is 37 bytes and the
structure is devm_kzalloc()ed, so it lives as long as the driver, and a
late write lands in memory that is still valid and is reinitialized by the
next command. bus_lock keeps commands from sharing it.
This deliberately does not clear reply->data or reply->length on the
timeout path. Doing so races with qnap_mcu_receive_buf(), which reads both
after its
if (!reply->length)
return size;
check: clearing reply->data gives a NULL dereference, and clearing
reply->length alone removes the reply->received == reply->length exit
condition, so the copy loop runs until the uart chunk is consumed and
overruns the buffer. Leaving both set keeps the write bounded by
reply->length, which qnap_mcu_exec() has already checked against
sizeof(mcu->rx).
📍 영향받는 시스템
Linux kernel (mfd: qnap-mcu 드라이버 포함 버전)
⚔️ 공격 벡터
MCU로부터 지연된 응답이나 요청되지 않은 메시지를 전송하여 스택 메모리 오염 유도
🛡️ 대응 방법
수정된 Linux 커널 패치를 적용하여 수신 버퍼를 스택이 아닌 드라이버 구조체(devm_kzalloc)로 이동
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 최신 패치 버전인지 확인합니다.