Patch "tracing/hist: Fix issue of losting command info in error_log" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing/hist: Fix issue of losting command info in error_log

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-hist-fix-issue-of-losting-command-info-in-er.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8d84109995d41c246af4e36ece551691f9039c61
Author: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
Date:   Wed Dec 7 21:53:26 2022 +0800

    tracing/hist: Fix issue of losting command info in error_log
    
    [ Upstream commit 608c6ed3337850c767ab0dd6c583477922233e29 ]
    
    When input some constructed invalid 'trigger' command, command info
    in 'error_log' are lost [1].
    
    The root cause is that there is a path that event_hist_trigger_parse()
    is recursely called once and 'last_cmd' which save origin command is
    cleared, then later calling of hist_err() will no longer record origin
    command info:
    
      event_hist_trigger_parse() {
        last_cmd_set()  // <1> 'last_cmd' save origin command here at first
        create_actions() {
          onmatch_create() {
            action_create() {
              trace_action_create() {
                trace_action_create_field_var() {
                  create_field_var_hist() {
                    event_hist_trigger_parse() {  // <2> recursely called once
                      hist_err_clear()  // <3> 'last_cmd' is cleared here
                    }
                    hist_err()  // <4> No longer find origin command!!!
    
    Since 'glob' is empty string while running into the recurse call, we
    can trickly check it and bypass the call of hist_err_clear() to solve it.
    
    [1]
     # cd /sys/kernel/tracing
     # echo "my_synth_event int v1; int v2; int v3;" >> synthetic_events
     # echo 'hist:keys=pid' >> events/sched/sched_waking/trigger
     # echo "hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(\
    pid,pid1)" >> events/sched/sched_switch/trigger
     # cat error_log
    [  8.405018] hist:sched:sched_switch: error: Couldn't find synthetic event
      Command:
    hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                                                              ^
    [  8.816902] hist:sched:sched_switch: error: Couldn't find field
      Command:
    hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                              ^
    [  8.816902] hist:sched:sched_switch: error: Couldn't parse field variable
      Command:
    hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
                              ^
    [  8.999880] : error: Couldn't find field
      Command:
               ^
    [  8.999880] : error: Couldn't parse field variable
      Command:
               ^
    [  8.999880] : error: Couldn't find field
      Command:
               ^
    [  8.999880] : error: Couldn't create histogram for field
      Command:
               ^
    
    Link: https://lore.kernel.org/linux-trace-kernel/20221207135326.3483216-1-zhengyejian1@xxxxxxxxxx
    
    Cc: <mhiramat@xxxxxxxxxx>
    Cc: <zanussi@xxxxxxxxxx>
    Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers")
    Signed-off-by: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index b8f1f0eadd2e..96d159af5194 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6433,7 +6433,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
 	/* Just return zero, not the number of registered triggers */
 	ret = 0;
  out:
-	if (ret == 0)
+	if (ret == 0 && glob[0])
 		hist_err_clear();
 
 	return ret;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux