security(core): harden user memory access, runtime CPU controls, and low-level fault containment#11
Open
minto-dane wants to merge 6 commits intotas0dev:devfrom
Open
security(core): harden user memory access, runtime CPU controls, and low-level fault containment#11minto-dane wants to merge 6 commits intotas0dev:devfrom
minto-dane wants to merge 6 commits intotas0dev:devfrom
Conversation
Introduce a minimal append-only audit ring buffer for recording fault, quarantine, deny, and recovery events from the core runtime. Export the audit module from the core crate so later hardening changes can report abnormal conditions without relying on panic output alone.
Enable supervisor write-protect, UMIP, SMEP/SMAP reinforcement, and supported speculation-control state during core runtime initialization. Reassert hardening state on timer entry and replace the boot CPU APIC table assertion with an audited fallback path.
Convert memory initialization, syscall entry, and ELF loading to use page-table-walk usercopy helpers instead of temporary user address-space switching. Keep kernel CR3 active during kernel-side copies, tighten user mapping permissions, and return explicit initialization errors from paging setup.
Route filesystem, exec, generic I/O, and pipe descriptor paths through the hardened usercopy helpers. Replace direct user-pointer reads and writes in these runtime paths while preserving the existing fd table model used by the service stack.
Replace remaining direct user-buffer accesses in process control, signal delivery, timekeeping, framebuffer, and mprotect-related syscall paths with the hardened copy helpers. Add bounded heap-base randomization and explicit handling for futex wake-queue overflow instead of relying on debug assertions.
… faults Replace panic-prone mailbox bookkeeping and unexpected thread or context return paths with explicit audit logging and containment behavior. Record GDT lookup failures, IPC mailbox corruption, kernel stack guard faults, and scheduler dead-end conditions without relying on silent corruption or unchecked panic paths.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Owner
|
cargo runで実行確認をしてから再メンションしてください |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
この PR は
src/coreの low-level runtime hardening を目的とした変更です。主に次の 3 点を改善しています。module 実装や service 構造の変更は含めず、並行して進んでいる別作業と衝突しにくい範囲に限定しています。
変更点
1. audit 基盤を追加
対象:
src/core/audit.rssrc/core/lib.rs変更内容:
src/core/audit.rsを追加src/core/lib.rsからauditを公開理由:
panic や silent failure に頼らず、異常を記録して追跡できるようにするためです。
2. CPU runtime hardening を強化
対象:
src/core/cpu.rssrc/core/interrupt/timer.rssrc/core/percpu.rs変更内容:
CR0.WPを有効化UMIPを有効化SMEP/SMAPを有効化・再適用IBPB/SPEC_CTRLのサポート検出と再適用を追加assert!を除去し、audit 付き fallback に変更理由:
runtime 中に hardening 状態が崩れたまま動くリスクを減らすためです。
3. user memory access を page-table-walk ベースへ移行
対象:
src/core/init/mod.rssrc/core/mem/mod.rssrc/core/mem/paging.rssrc/core/mem/user.rssrc/core/syscall/mod.rssrc/core/task/elf.rs変更内容:
Resultベースに変更copy_from_user/copy_to_userを整備理由:
kernel が user memory を扱う経路を、より KPTI に整合した安全な実装へ寄せるためです。
4. fs / exec / pipe / io 系 syscall の user buffer handling を harden
対象:
src/core/syscall/exec.rssrc/core/syscall/fs.rssrc/core/syscall/io.rssrc/core/syscall/pipe.rssrc/core/task/fd_table.rs変更内容:
理由:
よく使われる syscall 経路で、壊れた user pointer が kernel 側の不正アクセスや不安定動作につながるのを防ぐためです。
5. process / signal / time / vga / pgroup 系 syscall の usercopy を harden
対象:
src/core/syscall/pgroup.rssrc/core/syscall/process.rssrc/core/syscall/signal.rssrc/core/syscall/time.rssrc/core/syscall/vga.rs変更内容:
wait,arch_prctl,clock_gettime, framebuffer info 返却の helper 化debug_assert!依存から audit + drop に変更理由:
構造体の user/kernel 受け渡しや process 制御系 syscall を、他の hardened path と同じ基準で安全化するためです。
6. low-level fault containment を追加
対象:
src/core/mem/gdt.rssrc/core/syscall/ipc.rssrc/core/task/context.rssrc/core/task/scheduler.rssrc/core/task/thread.rs変更内容:
理由:
低レイヤ metadata の破損や想定外状態が、opaque な panic や silent corruption に繋がるのを防ぐためです。
この PR の目的
この PR の主目的は、
src/coreの runtime path を次の方向へ改善することです。module や service の構造変更をこの PR に含めると差分が大きくなりすぎ、並行作業とも競合しやすいため、この PR では hardening に集中しています。
互換性
既存の service stack や runtime ABI を壊さない範囲で変更しています。
維持しているもの:
コミット構成
8a617afobservability(core): add append-only audit log infrastructure0b551bbsecurity(core): enable runtime CPU hardening controlsf05c489security(core): move user memory access to page-table-walk primitivese0c57c1security(core): harden fs, exec, and pipe user-buffer handling1d4f130security(core): update process and signal syscalls for hardened usercopy2b12efereliability(core): add audit-backed containment for low-level runtime faults