public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] dtprobed: use /proc/$pid/map_files, not the filename of the mapping
@ 2025-12-02 23:04 Nick Alcock
  2025-12-04  6:18 ` Eugene Loh
  2026-01-20 16:20 ` [PATCH v2] " Nick Alcock
  0 siblings, 2 replies; 13+ messages in thread
From: Nick Alcock @ 2025-12-02 23:04 UTC (permalink / raw)
  To: dtrace-devel, dtrace

When hunting down a text mapping, prf->prf_mapname is equivalent to
looking at the symlink target of the /proc/$pid/map_files/* file, so
opening that opens (say) /usr/bin/blah. If we use Pmap_mapfile_name()
instead, we get the name of the actual /proc/$pid/map_files file
itself. This looks like a symlink, but it's actually magic: it points to
the target of the mapping even if that target is in a different
filesystem namespace, and you can dereference and open it to get the
contents of the mapping even if the symlink is apparently "broken".
DTrace already uses this elsewhere in USDT probe lookup, so we can
surely use it here as well.

Fixes e.g. running programs with probes out of /home (which is jailed
away from dtprobed by dtprobed's systemd service file).

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
---
 dtprobed/dtprobed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dtprobed/dtprobed.c b/dtprobed/dtprobed.c
index a808586559d96..9a6928055cd13 100644
--- a/dtprobed/dtprobed.c
+++ b/dtprobed/dtprobed.c
@@ -487,7 +487,7 @@ handle_usdt_notes(pid_t pid, uintptr_t addr)
 		fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapping (process dead?)\n",
 			 pid);
 		goto out;
-	} else if ((fn = prf->prf_mapname) == NULL) {
+	} else if ((fn = Pmap_mapfile_name(P, mapp)) == NULL) {
 		fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapname (process dead?)\n",
 			 pid);
 		goto out;

base-commit: 6e94c7d0a253806f85c39ff5f4e32a800d4cb6b6
-- 
2.51.0.284.g117bcb8de7


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-02-12 18:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 23:04 [PATCH] dtprobed: use /proc/$pid/map_files, not the filename of the mapping Nick Alcock
2025-12-04  6:18 ` Eugene Loh
2026-01-20 16:19   ` Nick Alcock
2026-01-20 16:20 ` [PATCH v2] " Nick Alcock
2026-01-20 19:24   ` [DTrace-devel] " Eugene Loh
2026-02-12 18:13     ` Eugene Loh
2026-02-12 18:18       ` Nick Alcock
2026-02-12 18:28         ` Kris Van Hees
2026-02-12 18:37           ` Kris Van Hees
2026-02-12 18:43             ` Kris Van Hees
2026-02-12 18:49               ` Eugene Loh
2026-02-12 18:51                 ` Kris Van Hees
2026-02-12 18:56                   ` Nick Alcock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox