Skip to content

Add mprotect syscall events#367

Open
Aegrah wants to merge 9 commits into
elastic:mainfrom
Aegrah:aegrah/mprotect-events
Open

Add mprotect syscall events#367
Aegrah wants to merge 9 commits into
elastic:mainfrom
Aegrah:aegrah/mprotect-events

Conversation

@Aegrah

@Aegrah Aegrah commented Jul 17, 2026

Copy link
Copy Markdown

Summary

Collect successful executable-memory mprotect() calls as an eBPF-only Quark event.

sys_enter_mprotect records address, length, and protection when PROT_EXEC is requested. sys_exit_mprotect correlates the call, deletes its state, and emits only when the syscall succeeded. Emitted masks are X, RX, WX, and RWX; non-executable masks and failed calls are suppressed. No kprobe fallback is added.

Issue: https://github.com/elastic/endpoint-dev/issues/20408

Workflow and proof

The contract workflow built and tested Quark, regenerated package/schema outputs, built Endpoint, ran focused unit/EAF tests, deployed through Fleet, and asserted Elasticsearch output.

  • Preflight 20260722T124741Z-mprotect-preflight: PASS
  • Fleet acceptance 20260722T142745Z-mprotect on Stack/Agent/Endpoint 9.4.2: PASS
  • Elasticsearch semantic assertion: four X/RX/WX/RWX documents checked
  • Realistic workstation qualification 20260722T103000Z-mprotect-realistic-smoke: PASS
3,708 Endpoint documents / 4,737 action values
exec: 523 (11.04%); mprotect: 6 (0.13%, 0.16% document coverage)
mprotect executables: /usr/bin/node 5; chromium headless_shell 1
masks: RWX 6 (100%)

Companion PR

Aegrah and others added 2 commits July 17, 2026 16:55
Collect only read-write protection changes to keep event volume bounded while exposing raw and decoded protection data to consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Preserve the new CLOCK_BOOTTIME contract while moving the mprotect queue flag to the next available bit.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Aegrah
Aegrah requested a review from nicholasberlin July 20, 2026 08:06
@Aegrah Aegrah self-assigned this Jul 20, 2026
@Aegrah Aegrah added the enhancement New feature or request label Jul 20, 2026
@Aegrah Aegrah changed the title Add mprotect syscall events [WIP] Add mprotect syscall events Jul 20, 2026
Aegrah and others added 3 commits July 20, 2026 12:03
Exercise every suppressed protection mask and keep the public event representation and documentation consistent.

Co-authored-by: Cursor <cursoragent@cursor.com>
Describe the permission-bit filter without implying that optional protection modifiers are rejected.
Correlate syscall entry and exit so only successful X, RX, WX, and RWX requests reach the event stream.
@Aegrah
Aegrah marked this pull request as ready for review July 23, 2026 11:48
@Aegrah
Aegrah requested a review from a team as a code owner July 23, 2026 11:48
@Aegrah
Aegrah removed the request for review from a team July 23, 2026 11:48
@haesbaert

Copy link
Copy Markdown
Collaborator

heya, sorry for the delay, I'm trying to priorize things that are blocking others before my final date, I assume this is not WIP anymore as the title suggests?

Aegrah and others added 3 commits July 24, 2026 10:02
Read sys_exit_mprotect return values through the tracepoint layout instead of BPF_CORE_READ, and teach t_mprotect to skip W^X-rejected executable transitions while still validating every successful X/RX/WX/RWX request the kernel accepts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exclude the mprotect quark-test on RHEL 9.3 alongside the existing memfd and shmget exclusions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Aegrah Aegrah changed the title [WIP] Add mprotect syscall events Add mprotect syscall events Jul 24, 2026
@Aegrah
Aegrah requested a review from haesbaert July 24, 2026 11:00
@Aegrah

Aegrah commented Jul 24, 2026

Copy link
Copy Markdown
Author

Correct @haesbaert. We are passing unit tests now and should be g2g for an initial review! Removed the WIP from the title. Please be thorough on this one; any feedback I can use to improve anything pushed in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants