[DTrace-devel] [PATCH] Cast should not change writable

Kris Van Hees kris.van.hees at oracle.com
Mon Oct 28 20:19:08 UTC 2024


On Tue, Oct 22, 2024 at 04:47:27PM -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>

> ---
>  libdtrace/dt_parser.c                  |  4 ++++
>  test/unittest/types/tst.castwritable.d | 22 ++++++++++++++++++++++
>  test/unittest/types/tst.castwritable.r |  1 +
>  3 files changed, 27 insertions(+)
>  create mode 100644 test/unittest/types/tst.castwritable.d
>  create mode 100644 test/unittest/types/tst.castwritable.r
> 
> diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
> index 59293ebce..325ba881e 100644
> --- a/libdtrace/dt_parser.c
> +++ b/libdtrace/dt_parser.c
> @@ -4209,6 +4209,10 @@ asgn_common:
>  			dt_cook_taint_alloca(lp, NULL, rp);
>  
>  		dt_node_type_propagate(lp, dnp); /* see K&R[A7.5] */
> +
> +		if (rp->dn_flags & DT_NF_WRITABLE)
> +			dnp->dn_flags |= DT_NF_WRITABLE;
> +
>  		dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
>  		break;
>  	}
> diff --git a/test/unittest/types/tst.castwritable.d b/test/unittest/types/tst.castwritable.d
> new file mode 100644
> index 000000000..1b419228c
> --- /dev/null
> +++ b/test/unittest/types/tst.castwritable.d
> @@ -0,0 +1,22 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION:  casting keeps a variable writable.
> + *
> + * SECTION: Types, Operators, and Expressions/Constants
> + */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> +	x = (char *) alloca(8);
> +	*((long long*)x) = 0x0067666564636261;
> +	trace(stringof(x));
> +	exit(0);
> +}
> diff --git a/test/unittest/types/tst.castwritable.r b/test/unittest/types/tst.castwritable.r
> new file mode 100644
> index 000000000..b5b9ef6c6
> --- /dev/null
> +++ b/test/unittest/types/tst.castwritable.r
> @@ -0,0 +1 @@
> +abcdefg
> -- 
> 2.43.5
> 



More information about the DTrace-devel mailing list