🇰🇷 한글 설명
Linux 커널의 comedi 드라이버에서 초기화되지 않은 메모리가 커널 공간에서 사용자 공간으로 복사되는 정보 누출 취약점입니다. do_insn_ioctl()과 do_insnlist_ioctl() 함수에서 할당된 버퍼를 완전히 채우지 않아 나머지 부분의 초기화되지 않은 커널 데이터가 유저스페이스로 유출됩니다.
💡 쉬운 설명
리눅스 커널의 특정 드라이버에서 메모리 정리를 제대로 하지 않아 민감한 커널 정보가 일반 사용자에게 노출될 수 있는 문제입니다. 로컬 사용자가 ioctl() 호출을 통해 초기화되지 않은 커널 메모리 데이터를 읽을 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
comedi: Fix use of uninitialized memory in do_insn_ioctl() and do_insnlist_ioctl()
syzbot reports a KMSAN kernel-infoleak in `do_insn_ioctl()`. A kernel
buffer is allocated to hold `insn->n` samples (each of which is an
`unsigned int`). For some instruction types, `insn->n` samples are
copied back to user-space, unless an error code is being returned. The
problem is that not all the instruction handlers that need to return
data to userspace fill in the whole `insn->n` samples, so that there is
an information leak. There is a similar syzbot report for
`do_insnlist_ioctl()`, although it does not have a reproducer for it at
the time of writing.
One culprit is `insn_rw_emulate_bits()` which is used as the handler for
`INSN_READ` or `INSN_WRITE` instructions for subdevices that do not have
a specific handler for that instruction, but do have an `INSN_BITS`
handler. For `INSN_READ` it only fills in at most 1 sample, so if
`insn->n` is greater than 1, the remaining `insn->n - 1` samples copied
to userspace will be uninitialized kernel data.
Another culprit is `vm80xx_ai_insn_read()` in the "vm80xx" driver. It
never returns an error, even if it fails to fill the buffer.
Fix it in `do_insn_ioctl()` and `do_insnlist_ioctl()` by making sure
that uninitialized parts of the allocated buffer are zeroed before
handling each instruction.
Thanks to Arnaud Lecomte for their fix to `do_insn_ioctl()`. That fix
replaced the call to `kmalloc_array()` with `kcalloc()`, but it is not
always necessary to clear the whole buffer.
📍 영향받는 시스템
Linux kernel comedi 드라이버 (2022년 이후 버전부터 영향받음)
⚔️ 공격 벡터
로컬 공격: 권한이 없는 사용자가 comedi 장치(/dev/comedi*)에 대한 ioctl() 호출을 통해 초기화되지 않은 커널 메모리 읽기
🛡️ 대응 방법
Linux 커널 패치를 포함한 최신 버전으로 업데이트 또는 comedi 드라이버 재컴파일
🔧 검증 코드
comedi 드라이버 로드 여부와 최근 comedi 관련 커널 로그를 확인하여 취약점 영향 상태 파악
lsmod | grep comedi && dmesg | grep -i comedi | tail -5