-
Notifications
You must be signed in to change notification settings - Fork 369
ebpf: add bpf_d_path helper function #1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
tamird
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test.
|
I use fentry/vfs_open as the mount point, but during compilation, I get the error: "helper call is not allowed in probe". How should I test this? |
|
@cppcoffee, this pull request is now in conflict and requires a rebase. |
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the bpf_d_path helper function to aya-ebpf, enabling BPF programs to convert kernel path structures to human-readable path strings. This addresses issue #1087 by providing a way to extract filesystem paths from kernel data structures.
- Added
bpf_d_pathhelper function implementation - Created comprehensive integration tests for the new helper
- Updated public API to expose the path bindings and helper function
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| xtask/public-api/aya-ebpf.txt | Updates public API exports to include path bindings and bpf_d_path function |
| test/integration-test/src/tests/bpf_d_path.rs | Integration test verifying bpf_d_path functionality with /dev/null |
| test/integration-test/src/tests.rs | Adds bpf_d_path module to test suite |
| test/integration-test/src/lib.rs | Registers BPF_D_PATH test binary |
| test/integration-ebpf/src/bpf_d_path.rs | BPF program implementation using bpf_d_path in fentry context |
| test/integration-ebpf/Cargo.toml | Adds bpf_d_path binary configuration |
| test/integration-common/src/lib.rs | Defines shared TestResult struct and constants |
| ebpf/aya-ebpf/src/helpers.rs | Implements bpf_d_path helper function wrapper |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ) | ||
| }; | ||
|
|
||
| result.len = dest.len(); |
Copilot
AI
Sep 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be result.len = data.len(); instead of dest.len(). The current code sets the length to the buffer size rather than the actual path length returned by bpf_d_path.
| result.len = dest.len(); | |
| result.len = data.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| unsafe { | ||
| memcpy( | ||
| result.buf.as_mut_ptr(), | ||
| data.as_ptr() as *mut u8, | ||
| data.len(), | ||
| ) | ||
| }; | ||
|
|
||
| result.len = dest.len(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Report actual bytes returned by bpf_d_path
result.len is populated with dest.len() rather than the number of bytes copied from bpf_d_path. When the helper returns a shorter path than the buffer, the length published to user space is still PATH_BUF_LEN, so the integration test will happily read uninitialized/truncated bytes and cannot detect if the helper returned an empty or partial path. Replace the assignment with the length of data so the test exercises the real path size.
Useful? React with 👍 / 👎.
Hi, this helper works from LSM programs, you can take a look here |
Fixed #1087
This change is