Re: [PATCH] Need -w for destructive actions, even if clause is not used
Eugene Loh <[email protected]>
| Newsgroups | dev.linux.lists.dtrace |
|---|---|
| Message-ID | <[email protected]> |
On 8/1/25 11:36, Kris Van Hees wrote: > On Fri, Jul 11, 2025 at 12:40:24AM -0400, [email protected] wrote: >> From: Eugene Loh <[email protected]> >> >> If a clause includes a destructive action but -w is not used, dtrace >> should not start up, even if the clause is ignored (due to -Z). >> Solaris treated this as a runtime error. We should do the same. >> >> diff --git a/test/unittest/options/err.no-w-or-destructive2.d b/test/unittest/options/err.no-w-or-destructive2.d >> new file mode 100644 >> @@ -0,0 +1,25 @@ >> +/* >> + * ASSERTION: Without -w or -xdestructive, destructive operations are not ok, >> + * even if a clause will be ignored since it does not exist and >> + * -Z was specified. > This could do with some rewriting. Sorry, what does "this" refer to? The comment, the test, or the patch? > The issue is that DTrace used to always > load all tracing programs, and the kernel would activate them as needed. We > now only load programs for enabled probes (and with -Z active, we may load > some programs later). > > What we need to be testing here is that if any clauses of a tracing script > contain destructive actions, and we are using the script for probing, then > an error should be reported unless we are allowing destructive actions (-w > or -xdestructive). I think we have such a test? The case being tested here is where a destructive action is specified, no -w is specified, but the clause will not be exercised since the probe does not exist and -Z allows us to ignore it. In this case, should the script be accepted or rejected? The patch says the script should be rejected, which was the legacy behavior. (People familiar with the legacy implementation may understand why the legacy behavior was what it was, but the question now is whether that behavior should be changed.) >> +/* @@runtest-opts: -Z */ >> + >> +bogus:bogus:bogus:bogus >> +{ >> + system("echo ok"); >> +}