Skip to content

fix: skip /tmp extraction when profiling libraries are installed#526

Open
xroche wants to merge 1 commit intoDataDog:mainfrom
algolia:fix/avoid-tmp-extraction
Open

fix: skip /tmp extraction when profiling libraries are installed#526
xroche wants to merge 1 commit intoDataDog:mainfrom
algolia:fix/avoid-tmp-extraction

Conversation

@xroche
Copy link
Copy Markdown
Contributor

@xroche xroche commented Mar 26, 2026

Fixes #527.

Summary

When ddprof is installed as a package, skip writing executables and shared libraries to /tmp. Security scanners like CrowdStrike Falcon flag new executables in /tmp, and the extraction is pointless when the files already sit in standard system paths.

How

The loader constructor tries dlopen with the bare library name (libdd_profiling-embedded.so) before falling back to /tmp extraction. Per dlopen(3), a filename without a slash goes through the standard search order (DT_RPATH, LD_LIBRARY_PATH, DT_RUNPATH, ldconfig cache, /lib, /usr/lib). If found, nothing is written to /tmp.

exec_ddprof does the same for the daemon binary: try execvp (execvp(3), PATH search) before memfd_create + fexecve from embedded data.

Self-contained / ad-hoc usage (libraries not installed) falls through to the existing /tmp extraction. Default behavior is unchanged.

@xroche xroche force-pushed the fix/avoid-tmp-extraction branch 2 times, most recently from 17a47d1 to ec872ba Compare March 26, 2026 17:43
The loader constructor used to extract both libdd_profiling-embedded.so
and the ddprof executable to /tmp on every load. This triggers security
scanners (e.g. Falcon) that flag new executables in /tmp.

When ddprof is installed as a package, the .so already sits in a
standard library search path and the binary is already in PATH. The
extraction is unnecessary.

The loader now tries dlopen with a bare library name first. Per
dlopen(3), a filename without a slash is resolved through the standard
search order (DT_RPATH, LD_LIBRARY_PATH, DT_RUNPATH, ldconfig cache,
/lib, /usr/lib). If that succeeds, no files are written to /tmp at all.

exec_ddprof gains a similar fallback: try execvp (PATH search) before
resorting to memfd_create + fexecve from embedded data.

When the libraries are NOT installed (self-contained / ad-hoc usage),
both paths fall through to the existing /tmp extraction, so nothing
changes for that use case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xroche xroche force-pushed the fix/avoid-tmp-extraction branch from ec872ba to 9a467b0 Compare March 26, 2026 17:46
@xroche xroche marked this pull request as ready for review March 26, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loader extracts executables to /tmp, triggers security scanners

1 participant