🇰🇷 한글 설명
Linux 커널 RISC-V 아키텍처의 futex 구현에서, 사용자 포인터를 access_ok() 검사 후 untag하지 않고 원시 주소로 원자 연산을 수행하는 문제가 해결되었습니다. 태그된 주소 ABI 사용 시 검증된 주소와 실제 접근 주소가 달라져 커널 임의 주소에 대한 원자 연산이 가능했던 취약점입니다.
💡 쉬운 설명
사용자 프로그램이 주소에 태그 비트를 붙여 커널 검사를 우회할 수 있었습니다. 이를 통해 일반 사용자 권한으로도 커널 메모리를 조작할 수 있었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
riscv: futex: untag the user pointer before the atomic access
access_ok() checks untagged_addr(uaddr), but arch_futex_atomic_op_inuser()
and futex_atomic_cmpxchg_inatomic() hand the raw uaddr to the inline asm
amoswap/amoadd/.../lr.w+sc.w through the "+m" (*uaddr) operand. When the
tagged address ABI is enabled (CONFIG_RISCV_ISA_SUPM, prctl
PR_SET_TAGGED_ADDR_CTRL with PMLEN != 0), those two addresses differ: a
user pointer whose top PMLEN bits hold a tag passes access_ok() after
untagging, but the atomic is then performed on the still-tagged raw
address.
Supervisor-mode data accesses are not subject to the U-mode pointer
masking (that is governed by menvcfg.PMM, which the kernel does not set),
so hardware does not strip the tag for the kernel's own access. With
Sv57 and PMLEN=16 the tag bits overlap the canonical-address bits, so a
tagged pointer can name a canonical kernel virtual address (e.g. in the
linear map) whose untagged form is a valid user address. An unprivileged
process can thus make FUTEX_WAKE_OP perform an atomic read-modify-write on
an arbitrary kernel address, with the matching FUTEX_OP_CMP_* result
serving as a read oracle.
get_user()/put_user()/raw_copy_{to,from}_user() already untag the pointer
after the access_ok() check; do the same in the futex helpers so the
atomic operates on the address that was actually validated.
📍 영향받는 시스템
포인터 마스킹(SUPM)과 Sv57을 사용하는 RISC-V 기반 Linux 커널 (패치 이전 버전)
⚔️ 공격 벡터
태그 비트가 포함된 포인터를 FUTEX_WAKE_OP에 전달해 커널 가상 주소에 원자 읽기-수정-쓰기를 수행
🛡️ 대응 방법
패치된 Linux 커널 버전으로 업데이트하고 재부팅
🔧 검증 코드
출력된 커널 버전이 배포판 보안 공지에서 해당 수정이 포함된 버전 이상인지 확인하고, RISC-V 시스템이 아니거나 SUPM 미사용 환경이면 영향이 제한적임을 판단합니다.