🇰🇷 한글 설명
Linux 커널의 KVM(SVM) 환경에서 INT3/INTO 명령어가 교체될 때 관련 없는 명령어를 건너뛰지 않아 발생하는 취약점입니다. CPU가 명령어를 실행한 후 KVM이 다음 RIP를 디코딩하기 전 코드 스트림이 변경되면 잘못된 RIP를 지정하여 게스트 상태를 손상시킬 수 있습니다. 이로 인해 Linux 게스트 커널에서 'Oops: int3' 패닉이 발생할 수 있습니다.
💡 쉬운 설명
가상 머신을 운영할 때, 컴퓨터가 실행 중인 코드를 수정하는 과정에서 실수가 발생하여 시스템이 갑자기 멈추거나 오류를 일으키는 문제입니다. 코드가 바뀌는 찰나의 순간을 제대로 확인하지 못해 엉뚱한 위치를 실행하려고 하기 때문에 발생합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
KVM: SVM: Don't skip unrelated instruction if INT3/INTO is replaced
When re-injecting a soft interrupt from an INT3, INT0, or (select) INTn
instruction, discard the exception and retry the instruction if the code
stream is changed (e.g. by a different vCPU) between when the CPU
executes the instruction and when KVM decodes the instruction to get the
next RIP.
As effectively predicted by commit 6ef88d6e36c2 ("KVM: SVM: Re-inject
INT3/INTO instead of retrying the instruction"), failure to verify that
the correct INTn instruction was decoded can effectively clobber guest
state due to decoding the wrong instruction and thus specifying the
wrong next RIP.
The bug most often manifests as "Oops: int3" panics on static branch
checks in Linux guests. Enabling or disabling a static branch in Linux
uses the kernel's "text poke" code patching mechanism. To modify code
while other CPUs may be executing that code, Linux (temporarily)
replaces the first byte of the original instruction with an int3 (opcode
0xcc), then patches in the new code stream except for the first byte,
and finally replaces the int3 with the first byte of the new code
stream. If a CPU hits the int3, i.e. executes the code while it's being
modified, then the guest kernel must look up the RIP to determine how to
handle the #BP, e.g. by emulating the new instruction. If the RIP is
incorrect, then this lookup fails and the guest kernel panics.
The bug reproduces almost instantly by hacking the guest kernel to
repeatedly check a static branch[1] while running a drgn script[2] on
the host to constantly swap out the memory containing the guest's TSS.
[1]: https://gist.github.com/osandov/44d17c51c28c0ac998ea0334edf90b5a
[2]: https://gist.github.com/osandov/10e45e45afa29b11e0c7209247afc00b
📍 영향받는 시스템
KVM(SVM)을 사용하는 Linux 커널 기반 가상화 환경
⚔️ 공격 벡터
멀티코어 환경에서 게스트 커널의 코드 패칭(text poke)이 일어나는 동안 vCPU 간의 메모리 상태 변화를 유도하여 발생
🛡️ 대응 방법
해당 취약점이 수정된 최신 버전의 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 릴리스 이후 버전인지 확인