https://sourceware.org/bugzilla/show_bug.cgi?id=34643
Bug ID: 34643
Summary: dwfl_linux_proc_report doesn't handle mount namespaces
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libdw
Assignee: unassigned at sourceware dot org
Reporter: godlygeek at gmail dot com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
If the process calling `dwfl_linux_proc_report` is in a different mount
namespace from the process being reported upon, elfutils fails to load the
files reported in /proc/$pid/maps (including the main executable, not just
shared libs).
For a small self-contained reproducer, you can try:
```
#!/bin/sh
dir="$PWD/dwfl-mount-ns-reproducer"
mkdir -p "$dir/target" "$dir/host"
cd "$dir"
cp /bin/sh target/
echo "Same mount namespace, eu-stack -b works:"
target/sh -c 'sleep 60' &
pid=$!
sleep 1
eu-stack --build-id --pid=$pid
kill $pid
wait $pid 2>/dev/null || true
echo
echo "Different mount namespace, eu-stack -b fails:"
unshare --mount --propagation private sh -c 'mount --bind target host && exec
host/sh -c "sleep 60"' &
pid=$!
sleep 1
eu-stack --build-id --pid=$pid
kill $pid
wait $pid 2>/dev/null || true
```
Because that needs to call `mount` it needs to be run as root, but you can test
it with for instance
docker run --privileged -it ubuntu:latest
And you'll need to install `eu-stack` in that container, which you could do
with
apt update -q && DEBIAN_FRONTEND=noninteractive apt install -y elfutils
Obviously that's testing with the Ubuntu packaged version of elfutils, but the
same issue occurs with a build of the latest tagged release from the git repo.
I believe this could be fixed by using /proc/$pid/root whenever opening files
using paths reported for a remote process.
Relates to https://github.com/bloomberg/pystack/issues/327
--
You are receiving this mail because:
You are on the CC list for the bug.