🇰🇷 한글 설명
Linux 커널 arm64 아키텍처의 엔트리 코드에서 ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD 워크어라운드가 잘못 구현되어 있었습니다. Cortex-A520 erratum 2966298 및 Cortex-A510 erratum 3117295를 완화하기 위한 TLBI+DSB 시퀀스가 마지막 명시적 메모리 접근 이후가 아닌 LDR 직전에 배치되어 있었습니다. 패치는 이 시퀀스를 ERET 직전으로 옮겨 KPTI 비활성화 환경에서만 적용되도록 재구성했습니다.
💡 쉬운 설명
일부 ARM 프로세서에서 커널이 메모리 접근 순서 문제로 인해 보호된 정보가 일시적으로 노출될 수 있는 결함이 있었습니다. 이번 수정은 보호 조치를 올바른 위치로 옮겨 이 위험을 줄입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
arm64: entry: fix ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
Currently the ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround isn't
quite right, as it is supposed to be applied after the last explicit
memory access, but is immediately followed by an LDR.
The ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround is used to
handle Cortex-A520 erratum 2966298 and Cortex-A510 erratum 3117295,
which are described in:
* https://developer.arm.com/documentation/SDEN2444153/0600/?lang=en
* https://developer.arm.com/documentation/SDEN1873361/1600/?lang=en
In both cases the workaround is described as:
| If pagetable isolation is disabled, the context switch logic in the
| kernel can be updated to execute the following sequence on affected
| cores before exiting to EL0, and after all explicit memory accesses:
|
| 1. A non-shareable TLBI to any context and/or address, including
| unused contexts or addresses, such as a `TLBI VALE1 Xzr`.
|
| 2. A DSB NSH to guarantee completion of the TLBI.
The important part being that the TLBI+DSB must be placed "after all
explicit memory accesses".
Unfortunately, as-implemented, the TLBI+DSB is immediately followed by
an LDR, as we have:
| alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
| tlbi vale1, xzr
| dsb nsh
| alternative_else_nop_endif
| alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0
| ldr lr, [sp, #S_LR]
| add sp, sp, #PT_REGS_SIZE // restore sp
| eret
| alternative_else_nop_endif
|
| [ ... KPTI exception return path ... ]
This patch fixes this by reworking the logic to place the TLBI+DSB
immediately before the ERET, after all explicit memory accesses.
The ERET is currently in a separate alternative block, and alternatives
cannot be nested. To account for this, the alternative block for
ARM64_UNMAP_KERNEL_AT_EL0 is replaced with a single alternative branch
to skip the KPTI logic, with the new shape of the logic being:
| alternative_insn "b .L_skip_tramp_exit_\@", nop, ARM64_UNMAP_KERNEL_AT_EL0
| [ ... KPTI exception return path ... ]
| .L_skip_tramp_exit_\@:
|
| ldr lr, [sp, #S_LR]
| add sp, sp, #PT_REGS_SIZE // restore sp
|
| alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
| tlbi vale1, xzr
| dsb nsh
| alternative_else_nop_endif
| eret
The new structure means that the workaround is only applied when KPTI is
not in use; this is fine as noted in the documented implications of the
erratum:
| Pagetable isolation between EL0 and higher level ELs prevents the
| issue from occurring.
... and as per the workaround description quoted above, the workaround
is only necessary "If pagetable isolation is disabled".
📍 영향받는 시스템
Cortex-A510/A520 기반 arm64 프로세서를 사용하며 KPTI가 비활성화된 Linux 커널 시스템
⚔️ 공격 벡터
로컬 사용자가 추측 실행(speculative execution) 부작용을 이용해 커널 메모리 정보를 유출하는 방식
🛡️ 대응 방법
패치가 적용된 최신 Linux 커널 버전으로 업데이트하고 재부팅
🔧 검증 코드
출력된 커널 버전이 배포판의 패치된 버전(업스트림 수정 커밋 포함) 이상인지 확인하고, 배포판 보안 공지에서 CVE-2024-26670 수정 여부를 대조합니다.