feat(gotter)!: add fn to hook symbol but exclude self - #2312
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
0c7b004 to
7248198
Compare
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results✅ No issues found! 📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 520be6b | Docs | Datadog PR Page | Give us feedback! |
05b1bde to
92dd335
Compare
a4a6346 to
9d4d601
Compare
BenchmarksComparisonBenchmark execution time: 2026-08-05 21:22:38 Comparing candidate commit 520be6b in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 138 metrics, 0 unstable metrics.
|
9d4d601 to
f19c984
Compare
92dd335 to
0b9de90
Compare
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e038403da
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| // Skip the hook's own library if requested. | ||
| if let Some(base) = skip_base { | ||
| if info.dlpi_addr as usize == base { |
There was a problem hiding this comment.
Handle non-PIE executables when skipping self
When hook_fn lives in a non-PIE main executable, dl_iterate_phdr reports the executable's dlpi_addr as 0 while dladdr(...).dli_fbase is the executable's load base, so this equality never matches and hook_symbol_excluding_self still patches the binary that contains the hook. In that context the hook's own executable can have its GOT entries redirected back to the hook, leading to recursion or crashes; please compare against the object's actual mapped range/PHDR base rather than dlpi_addr alone.
AGENTS.md reference: AGENTS.md:L70-L71
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not sure if this is common enough to do. Php tracer's GOT patching doesn't seem to care for this. WDYT @realFlowControl
There was a problem hiding this comment.
Non-PIE executables are uncommon but still in use; we should handle this.
There was a problem hiding this comment.
Got it. Im gonna be honest, I am not familiar with PIE, but I came to this commit: 520be6b off of reading https://one2bla.me/the-dark-arts/exploit-mitigations/position-independent-executables.html and some stack overflow blogs, with the help of my buddy claude.
Would appreciate special review over the above commit. Thanks :D
72c1fe9 to
65852e6
Compare
74f89d5 to
fd11980
Compare
2d9bca3 to
e9568ee
Compare
fd11980 to
520be6b
Compare

Stacked above feat(got-hook)!: add DT_HASH fallback, relocation type guard, and hook_symbol
PROF-15630
What does this PR do?
PHP needs to be able to hook libs and bins but skip its own exported fn.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.