Skip to content

Hardening pc-linux Memory Validation via Dynamic /proc/self/maps Discovery#469

Open
Shrey-N wants to merge 3 commits intonasa:mainfrom
Shrey-N:main
Open

Hardening pc-linux Memory Validation via Dynamic /proc/self/maps Discovery#469
Shrey-N wants to merge 3 commits intonasa:mainfrom
Shrey-N:main

Conversation

@Shrey-N
Copy link
Copy Markdown

@Shrey-N Shrey-N commented Apr 7, 2026

Checklist (Please check before submitting)

Describe the contribution

Mmitigates a root cause of memory related Denial of Service (DoS) vulnerabilities by hardening the pc-linux PSP memory validation layer.

Previously, the pc-linux PSP initialized its memory table with a permissive 0 to SIZE_MAX range, effectively bypassing all validation and masking potential security risks during development and simulation. This PR replaces that permissive range with a platform native discovery mechanism.

Key Changes:

  • Implemented CFE_PSP_InitMemoryTableFromProcMaps(), which parses /proc/self/maps at startup to identify mapped and accessible memory regions.
  • CFE_PSP_MemValidateRange now correctly enforces boundaries on Linux, rejecting invalid or unmapped addresses.
  • Increased CFE_PSP_MEM_TABLE_SIZE to 128 to accommodate the fragmented nature of Linux virtual memory maps.
  • Added an adjacent region merging (coalescing) algorithm to optimize the usage of the memory table while maintaining precise attribute mapping (Read/Write).

Testing performed

  1. Performed a clean build of pc-linux PSP to verify total compatibility and correct integration of the new /proc dependencies.
  2. Instrumented InitMemoryTableFromProcMaps with console traces to confirm the SysMemoryTable accurately mirrors the process's real memory map.
  3. Validated CFE_PSP_MemalidateRange behavior by confirming it correctly rejects unmapped addresses (e.g., 0xDEADBEEF) while accepting valid data/stack segments.
  4. Verified that identical adjacent memory segments are successfully merged, optimizing table usage and handling Linux fragmentation efficiently.

Expected behavior changes

  • CFE_PSP_MemValidateRange on the Linux platform will now correctly return failure (CFE_PSP_INVALID_MEM_ADDR) for non mapped addresses, rather than always returning CFE_PSP_SUCCESS.
  • API Change: No changes to the PSP API signatures.

System(s) tested on

  • Hardware: PC (x86_64)
  • OS: Linux (Generic)
  • Versions: cFS / PSP Latest

Additional context

Addresses the lack of platform native memory constraints on the pc-linux development platform, providing a security hardened reference for simulation based testing.

Fixes:- nasa/cFS#945

Contributor Info

  • Shrey Naithani
  • Note: CLA was previously submitted for the same issue to the cFS ecosystem.

Shrey-N added 3 commits April 7, 2026 17:02
Add function to initialize memory table from /proc/self/maps.
Removed commented out documentation for ES BSP memory initialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant