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

Eugene Loh eugene.loh at oracle.com
Fri Mar 24 01:22:53 UTC 2023


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
though I confess there is stuff here I do not understand.  E.g.,

     $ grep rds /proc/modules
     $ sudo build/run-dtrace -n 'BEGIN { trace(offsetof(struct 
rds_message, atomic)); exit(0) }'
     dtrace: description 'BEGIN ' matched 1 probe
     CPU     ID                    FUNCTION:NAME
       2      1                           :BEGIN         296

I do not need to have rds loaded?

(Also, the offset is nonzero, but I confess I don't know what CTF I'm 
using.)

On 3/23/23 08:13, 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>
> ---
>   .../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



More information about the DTrace-devel mailing list