[DTrace-devel] [PATCH 11/38] USDT module names may contain dots; but forbid "." and ".." names

Kris Van Hees kris.van.hees at oracle.com
Thu Jul 18 19:23:40 UTC 2024


On Thu, Jun 27, 2024 at 01:34:28AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees 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