🇰🇷 한글 설명
Zephyr ARM 포트에서 FPU를 활성화할 때, 컴파일러가 부동 소수점 타입을 사용하지 않는 코드에서도 FP 명령어를 생성할 수 있음에도 불구하고 FPU 레지스터 공유 설정이 자동으로 활성화되지 않는 결함이 있습니다. 이로 인해 컨텍스트 스위칭 시 callee-saved FP 레지스터가 보존되지 않아, 사용자 공간에서 스레드 간에 민감한 데이터가 유출되거나 데이터 오염이 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터가 작업을 전환할 때 계산용 임시 저장 공간(FPU 레지스터)을 제대로 비우거나 저장하지 않아, 다른 프로그램이 이전 프로그램의 비밀 정보를 훔쳐볼 수 있는 문제입니다. 이는 보안 경계가 무너져 데이터가 유출될 수 있는 위험을 초래합니다.
🇺🇸 원문 (English)
On the Zephyr ARM port, enabling the hardware FPU (CONFIG_FPU) forces the "Floating point ABI" choice, which defaults to CONFIG_FP_HARDABI. Both FP_HARDABI and FP_SOFTABI permit the compiler to emit hardware FP instructions in any function, even code that never uses floating-point types. However, the callee-saved FP registers (s16-s31 / d8-d15) are only saved and restored across a context switch when CONFIG_FPU_SHARING is enabled (arch/arm/core/cortex_m/swap_helper.S and arch/arm/core/cortex_a_r/swap_helper.S), and prior to this fix selecting an ABI did not enable FPU register sharing, which defaults off.
In a build that enables the FPU with the default ABI but leaves CONFIG_FPU_SHARING disabled, the kernel preserves no callee-saved FP register state across thread switches. The documented precondition for this "unshared" mode — that only a single thread ever executes FP instructions — is silently violated because the compiler may generate FP instructions in every thread.
Under CONFIG_USERSPACE, where threads are mutually isolated, this becomes an information-disclosure boundary crossing: a victim thread can leave secret-derived values in s16-s31, and a co-resident unprivileged thread can read those registers directly (FP register access is not privilege-gated), recovering data left behind by another thread. Without userspace the same defect causes cross-thread FP state corruption (a correctness fault). The leak is bounded to the 16 callee-saved single-precision registers and is opportunistic, so impact is low.
The fix makes FP_HARDABI and FP_SOFTABI select CONFIG_FPU_SHARING and tags every thread with K_FP_REGS at creation, so callee-saved FP state is always preserved across context switches whenever the compiler may emit FP instructions.
📍 영향받는 시스템
Zephyr RTOS (ARM 포트, CONFIG_FPU 활성화 및 CONFIG_FPU_SHARING 비활성화 상태)
⚔️ 공격 벡터
동일한 시스템 내에서 실행 중인 비특권 스레드가 컨텍스트 스위칭 직후 잔류하는 FP 레지스터 값을 직접 읽어 정보를 탈취함
🛡️ 대응 방법
FP_HARDABI 또는 FP_SOFT_ABI 선택 시 CONFIG_FPU_SHARING가 자동으로 활성화되도록 수정된 최신 Zephyr 커널로 업데이트
🔧 검증 코드
CONFIG_FPU는 활성화되어 있으나 CONFIG_FPU_SHARING가 설정되어 있지 않다면 취약한 상태임
grep -E 'CONFIG_FPU|CONFIG_FPU_SHARING' .config