Skip to content

Security: RustamSheoran/OS-C

Security

docs/SECURITY.md

OS-C Security Hardening

Current Mitigations

  • Syscall parameter validation
  • Panic on invalid operations
  • No libc (reduces attack surface)
  • Higher-half kernel (user/kernel isolation)

Planned Hardening

  • NX Enforcement: XD bit in page tables for non-executable data
  • ASLR: Randomize kernel heap and stack allocations
  • Stack Canaries: Magic values to detect buffer overflows
  • SMAP/SMEP: Hardware-enforced user/kernel access control
  • Capability System: Fine-grained permissions for syscalls

Implemented Hardening

  • Stack Canaries: Magic values in task structs, validated on context switches
  • NX Enforcement: XD bit support in paging for non-executable pages
  • ASLR: Basic randomization in kernel heap allocations
  • Syscall Filtering: Parameter validation and bounds checking
  • Memory Safety: Bounds checking in allocators and I/O operations

Implementation Details

Stack Canaries

struct task {
    // ...
    uint64_t canary;
    // ...
};

// Set on task creation
task->canary = 0xDEADBEEFDEADBEEF;

// Check on context switch
if (current_task->canary != 0xDEADBEEFDEADBEEF) {
    panic("Stack corruption detected");
}

NX Enforcement

// In paging.c map_page()
if (!(flags & EXEC)) {
    flags |= XD; // Non-executable
}

Syscall Validation

void syscall_dispatch(uint64_t num, uint64_t arg1, uint64_t arg2, uint64_t arg3) {
    // Bounds checking
    if (num >= MAX_SYSCALLS) {
        return -EINVAL;
    }
    // Parameter validation per syscall
}

Testing & Validation

  • Buffer overflow detection (canary checks)
  • Invalid syscall handling
  • Memory corruption prevention
  • Crash analysis with secure panic recovery

Compliance Goals

  • Linux kernel security best practices
  • No known vulnerabilities in implemented code
  • Defense-in-depth approach
  • Regular security audits

Attack Surface

  • Minimal: No network services, no user input parsing
  • Isolated: Kernel-only, no userspace services
  • Audited: All code reviewed for security issues

Future Roadmap

  • Implement SMEP/SMAP in CR4
  • Add full ASLR with entropy sources
  • Develop capability-based security model
  • Add runtime exploit detection
  • Hardware security feature enablement

There aren't any published security advisories