Skip to content

fix hard/sym link tracers for arm#764

Merged
matthyx merged 1 commit intomainfrom
randomx-arm
Mar 31, 2026
Merged

fix hard/sym link tracers for arm#764
matthyx merged 1 commit intomainfrom
randomx-arm

Conversation

@matthyx
Copy link
Copy Markdown
Contributor

@matthyx matthyx commented Mar 30, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved hardlink and symlink monitoring compatibility on arm64 architecture systems.

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Two eBPF program files receive conditional compilation directives to exclude specific syscall tracepoint handlers from arm64 builds. The enter_link and enter_symlink functions are wrapped with #ifndef __TARGET_ARCH_arm64 guards, while their *at counterparts remain unconditionally compiled.

Changes

Cohort / File(s) Summary
Architecture-specific conditional compilation
pkg/ebpf/gadgets/hardlink/program.bpf.c, pkg/ebpf/gadgets/symlink/program.bpf.c
Wrapped enter_link and enter_symlink syscall tracepoint handlers with #ifndef __TARGET_ARCH_arm64 / #endif directives to exclude them from arm64 builds, while enter_linkat and enter_symlinkat remain unconditionally compiled.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Hops through syscalls, checking the way,
"arm64? Not today, not today!"
With preprocessor guards, neat and tight,
These handlers skip arm64's sight,
Building lighter, hopping right! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: conditionally disabling hardlink and symlink tracers on arm64 architecture.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch randomx-arm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
pkg/ebpf/gadgets/hardlink/program.bpf.c (2)

37-84: Correct fix for arm64 compatibility.

Same as the symlink tracer—arm64 only implements linkat, not link. The guard is appropriate.

Consider adding a matching inline comment for consistency:

+// arm64 only implements linkat, not link
 `#ifndef` __TARGET_ARCH_arm64
 SEC("tracepoint/syscalls/sys_enter_link")

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/ebpf/gadgets/hardlink/program.bpf.c` around lines 37 - 84, The existing
guard excluding arm64 is correct because arm64 only implements linkat; keep the
`#ifndef` __TARGET_ARCH_arm64 around the SEC("tracepoint/syscalls/sys_enter_link")
enter_link function, and add a short inline comment above that guard (matching
the symlink tracer style) stating that arm64 implements only linkat so link
tracepoint is not available on arm64; ensure the symbol names referenced are
enter_link and SEC("tracepoint/syscalls/sys_enter_link") so reviewers can find
the function to update the comment.

41-43: Pre-existing: commented-out filtering code.

The gadget_should_discard_data_current() check is commented out here but is active in the symlink tracer. This appears to be pre-existing and unrelated to this PR, but may warrant a follow-up to align behavior between the two tracers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/ebpf/gadgets/hardlink/program.bpf.c` around lines 41 - 43, The hardlink
tracer currently has the gadget_should_discard_data_current() check commented
out while the symlink tracer keeps it active; restore consistent filtering by
re-enabling the same call in the hardlink tracer (uncomment or re-add
gadget_should_discard_data_current() with the same early-return pattern used in
the symlink tracer) inside the relevant probe function in program.bpf.c so both
tracers uniformly discard data when that predicate is true.
pkg/ebpf/gadgets/symlink/program.bpf.c (1)

32-79: Correct fix for arm64 compatibility.

The arm64 kernel ABI doesn't include the legacy symlink syscall—only symlinkat is available. The #ifndef __TARGET_ARCH_arm64 guard is the appropriate solution.

Consider adding a brief inline comment explaining why this exclusion is needed for future maintainers:

+// arm64 only implements symlinkat, not symlink
 `#ifndef` __TARGET_ARCH_arm64
 SEC("tracepoint/syscalls/sys_enter_symlink")

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/ebpf/gadgets/symlink/program.bpf.c` around lines 32 - 79, The current
guard using `#ifndef` __TARGET_ARCH_arm64 around the tracepoint handler
enter_symlink (SEC("tracepoint/syscalls/sys_enter_symlink")) is correct for
arm64 because the legacy symlink syscall is not present there; add a short
inline comment above that `#ifndef` explaining that arm64 uses symlinkat only and
therefore this tracepoint should be excluded on __TARGET_ARCH_arm64 to help
future maintainers locate the rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/ebpf/gadgets/hardlink/program.bpf.c`:
- Around line 37-84: The existing guard excluding arm64 is correct because arm64
only implements linkat; keep the `#ifndef` __TARGET_ARCH_arm64 around the
SEC("tracepoint/syscalls/sys_enter_link") enter_link function, and add a short
inline comment above that guard (matching the symlink tracer style) stating that
arm64 implements only linkat so link tracepoint is not available on arm64;
ensure the symbol names referenced are enter_link and
SEC("tracepoint/syscalls/sys_enter_link") so reviewers can find the function to
update the comment.
- Around line 41-43: The hardlink tracer currently has the
gadget_should_discard_data_current() check commented out while the symlink
tracer keeps it active; restore consistent filtering by re-enabling the same
call in the hardlink tracer (uncomment or re-add
gadget_should_discard_data_current() with the same early-return pattern used in
the symlink tracer) inside the relevant probe function in program.bpf.c so both
tracers uniformly discard data when that predicate is true.

In `@pkg/ebpf/gadgets/symlink/program.bpf.c`:
- Around line 32-79: The current guard using `#ifndef` __TARGET_ARCH_arm64 around
the tracepoint handler enter_symlink
(SEC("tracepoint/syscalls/sys_enter_symlink")) is correct for arm64 because the
legacy symlink syscall is not present there; add a short inline comment above
that `#ifndef` explaining that arm64 uses symlinkat only and therefore this
tracepoint should be excluded on __TARGET_ARCH_arm64 to help future maintainers
locate the rationale.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 897013e2-1205-4e37-ba4c-32d7312bf5dc

📥 Commits

Reviewing files that changed from the base of the PR and between 2b05e16 and 0b45678.

📒 Files selected for processing (2)
  • pkg/ebpf/gadgets/hardlink/program.bpf.c
  • pkg/ebpf/gadgets/symlink/program.bpf.c

@matthyx matthyx added the release Create release label Mar 31, 2026
@matthyx matthyx merged commit 0627d26 into main Mar 31, 2026
27 checks passed
@matthyx matthyx deleted the randomx-arm branch March 31, 2026 07:41
@matthyx matthyx moved this to To Archive in KS PRs tracking Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Create release

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants