Skip to content

feat(kernel): harden GRE protocol 47 admission - #187

Merged
kernalix7 merged 6 commits into
mainfrom
feature/gre-protocol-47
Aug 15, 2026
Merged

feat(kernel): harden GRE protocol 47 admission#187
kernalix7 merged 6 commits into
mainfrom
feature/gre-protocol-47

Conversation

@kernalix7

Copy link
Copy Markdown
Owner

Summary

Audit the GRE receive parser and wire IPv4 protocol 47 into NetworkStack as a structural admission gate. Malformed GRE remains silently consumed/dropped at the public boundary, with saturating admitted/dropped counters making the verdict observable.

Changes

  • enforce RFC 2784 receive-side version, discard-bit, and Reserved0 handling
  • parse all C/K/S optional-field layouts with strict aggregate bounds
  • validate C-bit checksums over the complete GRE header and payload, including odd lengths
  • reuse the shared validator from tunnel decapsulation
  • reject invalid IPv4 declared lengths and exclude Ethernet padding from the IP payload
  • dispatch protocol 47 without prematurely decapsulating or reinjecting inner payloads
  • expose read-only GRE admitted/dropped counters using saturating accounting
  • add parser, checksum, IPv4-boundary, dispatch, counter, and mutation-sensitive regressions

Related Issues

None.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace -- -D warnings
  • cargo build --workspace
  • focused GRE tests: 28 passed
  • strict Miri GRE tests: 28 passed
  • bash scripts/run-tests.sh: 4,650 passed, 0 skipped
  • bash scripts/run-qemu-test.sh: x86_64, aarch64, and riscv64 passed
  • mutation proof: bypassing validate_gre_packet makes the corrupt boundary test fail
  • five-lane final review: goal, QA, code quality, security, and context all PASS

Checklist

  • Public APIs are documented with /// comments
  • No new unsafe blocks or external dependencies
  • Existing license headers retained; no new files added
  • No hardcoded paths, credentials, or personal information
  • Documentation impact is limited to API/test comments; no user-facing docs required

Follow-up

IPv4 fragment reassembly is not implemented. A fragmented GRE packet can currently affect admission telemetry, but payloads are not decapsulated or delivered. Fragment rejection or reassembly should be addressed before live tunnel delivery.

Screenshots

Not applicable.

Reject GRE headers with reserved or deprecated flag bits, add parser coverage for optional-field offsets and truncation, and route IPv4 protocol 47 through the audited framing gate. The full-suite gate follows after the independent Landlock host-test race is fixed.
@kernalix7
kernalix7 merged commit 58a55e8 into main Aug 15, 2026
3 checks passed
@kernalix7
kernalix7 deleted the feature/gre-protocol-47 branch August 15, 2026 10:04
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