fix: additional checks for tmp fallback file in shmem - #2458
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportTracked Clippy
By file and crateBy file
By crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. Panic-inducing macros in particular should be avoided. In the future, this report may become a PR-blocking quality gate. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea4400a7da
ℹ️ 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
- 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 address that feedback".
| fn fallback_path<P: ?Sized + NixPath>(name: &P) -> nix::Result<CString> { | ||
| name.with_nix_path(|cstr| { | ||
| let mut path = "/tmp/libdatadog".to_string().into_bytes(); | ||
| let mut path = format!("/tmp/libdatadog-{}", getuid().as_raw()).into_bytes(); |
There was a problem hiding this comment.
Derive the fallback directory from the shared-memory owner
When the sidecar master runs as root and workers run under another UID, the initialization in datadog-sidecar/src/setup/thread_listener.rs calls set_shm_owner_uid(cred.uid) specifically to make the shared-memory file accessible across users. In a fallback environment such as AWS Lambda, however, the master now creates the file under /tmp/libdatadog-0, while the worker's NamedShmHandle::open computes /tmp/libdatadog-<worker uid> and therefore cannot find it; the directory's 0700 mode would also prevent traversal even if both used the master's path. This breaks all named cross-user IPC whenever POSIX shm_open is unavailable, so creation should select a namespace that the intended owner will also use and can traverse.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Hmm, indeed, if the sidecar and the worker can be run under different users, this makes things harder than I thought. Wdyt @bwoebi ? Do workers and the sidecar always run under the same user?
🔒 Cargo Deny Results📦
|
BenchmarksComparisonBenchmark execution time: 2026-09-03 12:33:33 Comparing candidate commit ea4400a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2 metrics, 0 unstable metrics.
|
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | ea4400a | 1788436400 | yannham/APMSP-3157 |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| write only interface | execution_time | 2.038µs | 2.060µs ± 0.005µs | 2.060µs ± 0.003µs | 2.063µs | 2.068µs | 2.071µs | 2.080µs | 1.00% | -0.316 | 2.777 | 0.26% | 0.000µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| write only interface | execution_time | [2.059µs; 2.061µs] or [-0.037%; +0.037%] | None | None | None |
Group 2
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | ea4400a | 1788436400 | yannham/APMSP-3157 |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| two way interface | execution_time | 20.980µs | 21.675µs ± 0.252µs | 21.626µs ± 0.144µs | 21.810µs | 22.129µs | 22.464µs | 22.561µs | 4.32% | 0.897 | 1.288 | 1.16% | 0.018µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| two way interface | execution_time | [21.640µs; 21.710µs] or [-0.161%; +0.161%] | None | None | None |
Baseline
Baseline benchmark details
Group 1
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | efbbf4c | 1788373668 | main |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| write only interface | execution_time | 2.037µs | 2.056µs ± 0.006µs | 2.056µs ± 0.003µs | 2.059µs | 2.064µs | 2.069µs | 2.097µs | 1.96% | 1.090 | 9.370 | 0.30% | 0.000µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| write only interface | execution_time | [2.055µs; 2.057µs] or [-0.041%; +0.041%] | None | None | None |
Group 2
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz | efbbf4c | 1788373668 | main |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| two way interface | execution_time | 20.665µs | 21.589µs ± 0.315µs | 21.525µs ± 0.143µs | 21.707µs | 22.152µs | 22.652µs | 23.566µs | 9.49% | 1.870 | 8.071 | 1.46% | 0.022µs | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| two way interface | execution_time | [21.545µs; 21.633µs] or [-0.202%; +0.202%] | None | None | None |
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
|
What does this PR do?
This PR hardens the permissions set on the tmp fallback file created by the sidecar for IPC.
Motivation
See https://datadoghq.atlassian.net/browse/APMSP-3157.