🇰🇷 한글 설명
Linux 커널의 Rocket NPU 드라이버에서 코어를 제거할 때 검색 범위가 줄어들어 마지막 코어가 제거되지 않고, 이후 재바인딩 시 할당되지 않은 배열 영역(rdev->cores)에 쓰기가 발생하는 메모리 범위 초과 문제입니다. 해당 취약점은 제거 시 모든 슬롯을 검색하도록 수정되었습니다.
💡 쉬운 설명
NPU 드라이버에서 장치를 떼어낼 때 마지막 코어를 제대로 찾지 못해 정리가 되지 않습니다. 그 상태로 다시 연결하면 정해진 메모리 범위를 넘어 데이터를 써서 시스템이 불안정해질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
accel/rocket: search every core slot when a core is removed
rocket_remove() decrements rdev->num_cores for each core it removes,
while find_core_for_dev() searches slots 0 to num_cores - 1. Unbinding
the cores in the order they were bound therefore loses the last one: by
the time it is removed the search range has already shrunk past its
slot, so find_core_for_dev() returns -1 and rocket_remove() gives up
without doing anything.
num_cores never reaches zero, rocket_device_fini() never runs, and the
file-scoped rdev keeps pointing at a device that is going away. Binding
the cores again starts from that stale count, because rocket_probe()
takes rdev->num_cores as the slot to fill. On an RK3588, which describes
three cores, the second round lands on slots 1, 2 and 3 while rdev->cores
was allocated with room for three:
rocket fdab0000.npu: Rockchip NPU core 1 version: 1179210309
rocket fdac0000.npu: Rockchip NPU core 2 version: 1179210309
rocket fdad0000.npu: Rockchip NPU core 3 version: 1179210309
The write to rdev->cores[3] is past the end of the array.
Nothing in tree reads the core array often enough to notice, so the
overrun is silent today. It turned up while testing a devfreq series on
top of this, where a worker walks every core a few times a second, and
UBSAN caught the first bool it read out of the overrun entry:
UBSAN: invalid-load in drivers/accel/rocket/rocket_devfreq.c:47:10
load of value 5 is not a valid value for type '_Bool'
Workqueue: devfreq_wq devfreq_monitor
Record how many slots were allocated and search all of them. Every core
is then found on removal, num_cores reaches zero, the device is torn down
and a later bind starts from a clean rdev.
This does not make unbinding a single core out of several work. probe
still takes num_cores as the slot to fill, so rebinding one core while
its siblings stay bound would write over a slot that is already in use,
and rocket_open() still reaches for cores[0] whether or not anything is
there. Both of those want more thought than a fix should carry.
Found by unbinding and rebinding all three cores on an Orange Pi 5 Plus.
With this applied, 25 unbind/rebind rounds and 5 module unload/reload
rounds run clean there: the cores land in slots 0, 1 and 2 every time,
whichever order they are bound in, and the shared supply goes back to a
single user after each round.
📍 영향받는 시스템
Rockchip NPU(Rocket 드라이버)를 사용하는 Linux 커널 (수정 이전 버전, RK3588 등)
⚔️ 공격 벡터
로컬 권한이 있는 사용자 또는 드라이버를 반복 바인딩/언바인딩하는 과정에서 배열 범위 초과 쓰기가 발생하며, 직접적인 원격 공격 경로는 확인되지 않음
🛡️ 대응 방법
패치된 Linux 커널로 업데이트하거나 해당 커밋(모든 코어 슬롯 검색)을 적용하고, 재부팅 또는 커널 모듈 재적재를 수행
🔧 검증 코드
커널 버전이 패치가 포함된 버전 이상인지 확인하고, rocket 드라이버 모듈이 존재하는지 확인합니다. 드라이버가 없으면 이 취약점의 영향을 받지 않습니다.
uname -r && grep -rl rocket /lib/modules/$(uname -r) 2>/dev/null | head -n 3