[DTrace-devel] [PATCH] sdt and syscall probe descriptions broken when multiple probes

Kris Van Hees kris.van.hees at oracle.com
Tue Oct 20 18:03:14 PDT 2020


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

On Mon, Oct 19, 2020 at 01:07:51AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> The sdt and syscall providers are broken in that, when a probe
> description corresponds to multiple probes, a BPF program is
> attached to only one of the probes.  E.g., syscall:::entry will
> attach a BPF program to only one probe, even though hundreds of
> probes are indicated!  The problem is that the attach function
> looks for an event_id, skipping the probe if there is no such ID,
> but the ID exists for only the "representative probe."
> 
> Change the attach() function so that, if the event_id has not
> yet been set, there is an attempt to set it.  This is how the
> dtrace and fbt providers behave.
> 
> What is surprising is that, with this fix, there are no XPASS
> tests.  That is, there had presumably been no XFAIL tests
> ("expected fails") that had been failing due *only* to this
> problem.  A quick survey of tests suggests that this is likely;
> remarkably few tests rely on such functionality, and those that
> do still fail due to other missing support (such as strings or
> other providers).
> 
> Therefore, add a test to check the fix.
> 
> Orabug: 32036431
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_prov_sdt.c            |  2 ++
>  test/unittest/syscall/tst.entry.sh | 50 ++++++++++++++++++++++++++++++
>  2 files changed, 52 insertions(+)
>  create mode 100755 test/unittest/syscall/tst.entry.sh
> 
> diff --git a/libdtrace/dt_prov_sdt.c b/libdtrace/dt_prov_sdt.c
> index 4b2ac31b..1414bdf3 100644
> --- a/libdtrace/dt_prov_sdt.c
> +++ b/libdtrace/dt_prov_sdt.c
> @@ -71,6 +71,8 @@ int tp_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
>  {
>  	tp_probe_t	*datap = prp->prv_data;
>  
> +	if (datap->event_id == -1)
> +		prp->prov->impl->probe_info(dtp, prp, NULL, NULL);
>  	if (datap->event_id == -1)
>  		return 0;
>  
> diff --git a/test/unittest/syscall/tst.entry.sh b/test/unittest/syscall/tst.entry.sh
> new file mode 100755
> index 00000000..fc14f7cc
> --- /dev/null
> +++ b/test/unittest/syscall/tst.entry.sh
> @@ -0,0 +1,50 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2020, 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.
> +
> +# Check that syscall:::entry picks up open*:entry.
> +
> +dtrace=$1
> +
> +DIRNAME="$tmpdir/entry.$$.$RANDOM"
> +mkdir -p $DIRNAME
> +cd $DIRNAME
> +
> +cat > main.c << EOF
> +#include <unistd.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +int main(int c, char **v) {
> +    while (open("/dummy/path", O_RDWR) == -1) sleep(1);
> +    return 0;
> +}
> +EOF
> +
> +gcc main.c
> +if [ $? -ne 0 ]; then
> +    echo ERROR: compilation failed
> +    cat main.c
> +    exit 1
> +fi
> +
> +./a.out &
> +pid=$!
> +
> +$dtrace $dt_flags -o tmp.log -n 'syscall:::entry /pid == '$pid'/ {}  tick-5s {exit(0)}'
> +if [ $? -ne 0 ]; then
> +    echo ERROR: dtrace failed
> +    exit 1
> +fi
> +
> +kill %1
> +
> +if [ `grep -c '^ *open.*:entry *$' tmp.log` -lt 4 ]; then
> +    echo ERROR: insufficient probe firings
> +    cat tmp.log
> +    exit 1
> +fi
> +
> +exit 0
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> 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