aya-rs/aya

Improve `uprobe` dynamic library path resolution to be `glibc`-agnostic

Opened this issue · 0 comments

Currently, when you provide Aya a target to attach a uprobe to, it has the following resolution strategy:

fn resolve_attach_path(target: &Path, pid: Option<pid_t>) -> Result<Cow<'_, Path>, UProbeError> {

  1. Check if the pid is set; if so find the lib in the proc maps
  2. Check if an absolute path is provided; if so assume that the path is to a binary/library path
  3. Otherwise, fallback to looking up a dynamic library in ld.so.cache

However, the use of ld.so.cache is specific to glibc. Even though Aya can be compiled to musl targets, this prevents using uprobes with dynamic library resolution in non-glibc environments, such as Alpine.

Improve the uprobe dynamic library path resolution to be glibc-agnostic.
This will likely involve searching for the provided dynamic library in PATH ourselves, instead of relying ld.so.cache.