🇰🇷 한글 설명
Linux 커널의 BPF(Berkeley Packet Filter) 프로그램 실행 중 부호 있는 나눗셈(sdiv) 및 나머지 연산(smod)에서 오버플로가 발생할 수 있는 취약점입니다. 특히 x86_64 아키텍처에서 최소값(LLONG_MIN)을 -1로 나눌 경우 커널 예외가 발생하여 시스템이 충돌(Kernel Crash)할 수 있습니다.
💡 쉬운 설명
컴퓨터가 숫자를 계산할 때, 표현할 수 있는 범위를 벗어나는 잘못된 나눗셈을 수행하여 시스템이 갑자기 멈추거나 꺼질 수 있는 문제입니다. 특정 조건에서 계산 결과가 너무 커져서 컴퓨터가 감당하지 못해 발생하는 오류입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix a sdiv overflow issue
Zac Ecob reported a problem where a bpf program may cause kernel crash due
to the following error:
Oops: divide error: 0000 [#1] PREEMPT SMP KASAN PTI
The failure is due to the below signed divide:
LLONG_MIN/-1 where LLONG_MIN equals to -9,223,372,036,854,775,808.
LLONG_MIN/-1 is supposed to give a positive number 9,223,372,036,854,775,808,
but it is impossible since for 64-bit system, the maximum positive
number is 9,223,372,036,854,775,807. On x86_64, LLONG_MIN/-1 will
cause a kernel exception. On arm64, the result for LLONG_MIN/-1 is
LLONG_MIN.
Further investigation found all the following sdiv/smod cases may trigger
an exception when bpf program is running on x86_64 platform:
- LLONG_MIN/-1 for 64bit operation
- INT_MIN/-1 for 32bit operation
- LLONG_MIN%-1 for 64bit operation
- INT_MIN%-1 for 32bit operation
where -1 can be an immediate or in a register.
On arm64, there are no exceptions:
- LLONG_MIN/-1 = LLONG_MIN
- INT_MIN/-1 = INT_MIN
- LLONG_MIN%-1 = 0
- INT_MIN%-1 = 0
where -1 can be an immediate or in a register.
Insn patching is needed to handle the above cases and the patched codes
produced results aligned with above arm64 result. The below are pseudo
codes to handle sdiv/smod exceptions including both divisor -1 and divisor 0
and the divisor is stored in a register.
sdiv:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L2
if tmp == 0 goto L1
rY = 0
L1:
rY = -rY;
goto L3
L2:
rY /= rX
L3:
smod:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L1
if tmp == 1 (is64 ? goto L2 : goto L3)
rY = 0;
goto L2
L1:
rY %= rX
L2:
goto L4 // only when !is64
L3:
wY = wY // only when !is64
L4:
[1] https://lore.kernel.org/bpf/tPJLTEh7S_DxFEqAI2Ji5MBSoZVg7_G-Py2iaZpAaWtM961fFTWtsnlzwvTbzBzaUzwQAoNATXKUlt0LZOFgnDcIyKCswAnAGdUF3LBrhGQ=@protonmail.com/
📍 영향받는 시스템
Linux Kernel (BPF를 사용하는 모든 시스템, 특히 x86_64 아키텍처)
⚔️ 공격 벡터
악의적으로 조작된 BPF 프로그램을 로드하여 커널 내에서 오버플로를 유도함으로써 시스템을 중단시킴
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 sdiv/smod 오버플로 예외 처리를 적용해야 함
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 최신 패치 버전인지 확인하십시오.