public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: dtrace-devel@oss.oracle.com, dtrace@lists.linux.dev
Cc: Eugene Loh <eugene.loh@oracle.com>
Subject: [PATCH v3] dtprobed: use /proc/$pid/map_files, not the filename of the mapping
Date: Thu, 12 Feb 2026 19:17:29 +0000	[thread overview]
Message-ID: <20260212191729.225384-1-nick.alcock@oracle.com> (raw)

From: Eugene Loh <eugene.loh@oracle.com>

Instead of using prf->prf_mapname (which resolves to the mapped file's
target), use Pmap_mapfile_name() to get the actual
/proc/$pid/map_files/* path.  These magic symlinks can be opened even
when their corresponding files are deleted or in an inaccessible
filesystem namespace, ensuring we can read the mapping contents
reliably.  DTrace already does this to read mappings during USDT probe
lookup.

(We still use prf->prf_mapname to determine the module name used in the
dof helper, and thus ultimately in the probespec, because that should be
an actual user-readable module name, not some random address-space-like
filename: it doesn't matter that that name might not exist on the
filesystem.  Thanks to Eugene Loh for spotting this and Kris van Hees
for fixing it.)

Fixes issues with probes in paths like /home when dtprobed
is sandboxed by systemd.

Tested on both systemd and non-systemd (non-jailed) systems, with USDT
programs running out of /tmp, /usr/local and /home.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
---
 dtprobed/dtprobed.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dtprobed/dtprobed.c b/dtprobed/dtprobed.c
index a808586559d96..34349deb028be 100644
--- a/dtprobed/dtprobed.c
+++ b/dtprobed/dtprobed.c
@@ -487,16 +487,17 @@ 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 (prf->prf_mapname == NULL ||
+		   (fn = Pmap_mapfile_name(P, mapp)) == NULL) {
 		fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapname (process dead?)\n",
 			 pid);
 		goto out;
 	}
-	mod = strrchr(fn, '/');
+	mod = strrchr(prf->prf_mapname, '/');
 	if (mod)
 		mod++;
 	else
-		mod = fn;
+		mod = prf->prf_mapname;
 	snprintf(dh.dofhp_mod, sizeof(dh.dofhp_mod), "%s", mod);
 
 	dh.dofhp_addr = mapp->pr_vaddr;

base-commit: 9abccde65bd924a5b63258eebb5210952709768d
prerequisite-patch-id: d178f9e04afa5cca97d93ef7659a72dff6d364b6
-- 
2.53.0.286.g870d7528e3


             reply	other threads:[~2026-02-12 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 19:17 Nick Alcock [this message]
2026-02-12 19:26 ` [PATCH v3] dtprobed: use /proc/$pid/map_files, not the filename of the mapping Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260212191729.225384-1-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox