run_cmd() passes its command string to eval using an unquoted $*. The
shell performs field splitting and pathname expansion before eval can
parse the quotes in that string.
For example, an event filter prev_comm == "a b" is applied as
prev_comm == "a b". A literal "*" surrounded by spaces inside a filter
can also expand to filenames in the current directory. The printed
command still contains the intended string, so --apply changes the
settings even though the preview looks correct.
Quote "$*" when passing it to eval to preserve the command string. This
fixes both per-event filters and histogram actions.
Fixes: 7e66ef0046cc ("tools/bootconfig: Add a script to generate ftrace
shell-command from bootconfig")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <[email protected]>
---
I tested this with hand-written configs in a temporary tracefs instance
on my Ubuntu machine, running kernel 7.0.0-38-generic, with recording
disabled. I checked both event filters and histogram action filters.
The original helper collapsed repeated spaces and expanded a literal *
into filenames. With the fix, the strings were preserved. Ordinary
string and numeric filters worked in both versions.
tools/bootconfig/scripts/bconf2ftrace.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/bootconfig/scripts/bconf2ftrace.sh
b/tools/bootconfig/scripts/bconf2ftrace.sh
index 7745c97e7abd..ea7b17d0d4d7 100755
--- a/tools/bootconfig/scripts/bconf2ftrace.sh
+++ b/tools/bootconfig/scripts/bconf2ftrace.sh
@@ -41,7 +41,7 @@ fi
run_cmd() { # command
echo "$*"
if [ x"$APPLY" != x ]; then # apply command
- eval $*
+ eval "$*"
fi
}
--
2.53.0