[DTrace-devel] [PATCH 11/38] USDT module names may contain dots; but forbid "." and ".." names
eugene.loh at oracle.com
eugene.loh at oracle.com
Thu Jun 27 05:34:28 UTC 2024
From: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
dtprobed/dof_stash.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/dtprobed/dof_stash.c b/dtprobed/dof_stash.c
index 62418b66..625572d5 100644
--- a/dtprobed/dof_stash.c
+++ b/dtprobed/dof_stash.c
@@ -231,6 +231,20 @@ make_probespec_name(const char *prov, const char *mod, const char *fn,
{
char *ret;
+ /*
+ * Ban "." and ".." as name components. Obviously names
+ * containing dots are commonplace (shared libraries,
+ * for instance), but allowing straight . and .. would
+ * have obviously horrible consequences. They can't be
+ * filenames anyway, and you can't create them with
+ * dtrace -h because they aren't valid C identifier names.
+ */
+ if (strcmp(prov, ".") == 0 || strcmp(prov, "..") == 0 ||
+ strcmp(mod, ".") == 0 || strcmp(mod, "..") == 0 ||
+ strcmp(fn, ".") == 0 || strcmp(fn, "..") == 0 ||
+ strcmp(prb, ".") == 0 || strcmp(prb, "..") == 0)
+ return NULL;
+
if (asprintf(&ret, "%s:%s:%s:%s", prov, mod, fn, prb) < 0) {
fuse_log(FUSE_LOG_ERR, "dtprobed: out of memory making probespec\n");
return NULL;
@@ -589,22 +603,6 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)
mod, fun, prb)) == NULL)
goto err_provider;
- /*
- * Ban "." and ".." as name components. Obviously names
- * containing dots are commonplace (shared libraries,
- * for instance), but allowing straight . and .. would
- * have obviously horrible consequences. They can't be
- * filenames anyway, and you can't create them with
- * dtrace -h because they aren't valid C identifier
- * names.
- */
- op = "probe name validation";
- probe_err = parsedfn;
-
- if (strcmp(parsedfn, ".") == 0 ||
- strcmp(parsedfn, "..") == 0)
- goto err_provider;
-
op = "probe module";
if ((mod_dir = make_state_dirat(prov_dir, mod, op, 0)) < 0)
--
2.18.4
More information about the DTrace-devel
mailing list