[DTrace-devel] [PATCH 2/6] test: add a test for libctf bug 30264

Kris Van Hees kris.van.hees at oracle.com
Fri May 12 14:05:08 UTC 2023


On Wed, Apr 19, 2023 at 04:41:27PM +0100, Nick Alcock via DTrace-devel wrote:
> If present, this bug breaks offsetof (and anything else requiring
> reliable offset info, like, oh, say, *any access*) to fields of
> unnamed structs/unions at nonzero offsets within their containing
> struct/union.
> 
> (We just check offsetof, because it's simpler than doing full access
> checks.  We check only the in-kernel CTF, because the D language does
> not support unnamed struct/union fields at all.)
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  .../types/tst.nested-unnamed-structs.d        | 32 +++++++++++++++++++
>  .../types/tst.nested-unnamed-structs.x        |  7 ++++
>  2 files changed, 39 insertions(+)
>  create mode 100644 test/unittest/types/tst.nested-unnamed-structs.d
>  create mode 100755 test/unittest/types/tst.nested-unnamed-structs.x
> 
> diff --git a/test/unittest/types/tst.nested-unnamed-structs.d b/test/unittest/types/tst.nested-unnamed-structs.d
> new file mode 100644
> index 0000000000000..a2b174434574d
> --- /dev/null
> +++ b/test/unittest/types/tst.nested-unnamed-structs.d
> @@ -0,0 +1,32 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2023, 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:
> + *	Check for the absence of a libctf bug breaking offsets of
> + *	members of nested unnamed structs in the kernel.
> + *	See https://sourceware.org/bugzilla/show_bug.cgi?id=30264
> + *
> + */
> +
> +#pragma D option quiet
> +
> +BEGIN {
> +	printf("offset is %i\n", offsetof(struct rds`rds_message, atomic));
> +}
> +
> +BEGIN
> +/ offsetof(struct rds`rds_message, atomic) == 0 /
> +{
> +	exit(1);
> +}
> +
> +BEGIN
> +/ offsetof(struct rds`rds_message, atomic) != 0 /
> +{
> +	exit(0);
> +}
> diff --git a/test/unittest/types/tst.nested-unnamed-structs.x b/test/unittest/types/tst.nested-unnamed-structs.x
> new file mode 100755
> index 0000000000000..47e579ed00f60
> --- /dev/null
> +++ b/test/unittest/types/tst.nested-unnamed-structs.x
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +
> +if ! $(grep -q '^rds ' /proc/modules); then
> +    exit 1
> +fi
> +
> +exit 0
> -- 
> 2.39.1.268.g9de2f9a303
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list