Patch "tracing: Handle synthetic event array field type checking correctly" has been added to the 5.8-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: Handle synthetic event array field type checking correctly

to the 5.8-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-handle-synthetic-event-array-field-type-chec.patch
and it can be found in the queue-5.8 subdirectory.

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



commit 65ac985f22f070ff239f0ef266cd67cda0baf236
Author: Tom Zanussi <zanussi@xxxxxxxxxx>
Date:   Tue Oct 13 09:17:57 2020 -0500

    tracing: Handle synthetic event array field type checking correctly
    
    [ Upstream commit 10819e25799aae564005b6049a45e9808797b3bb ]
    
    Since synthetic event array types are derived from the field name,
    there may be a semicolon at the end of the type which should be
    stripped off.
    
    If there are more characters following that, normal type string
    checking will result in an invalid type.
    
    Without this patch, you can end up with an invalid field type string
    that gets displayed in both the synthetic event description and the
    event format:
    
    Before:
    
      # echo 'myevent char str[16]; int v' >> synthetic_events
      # cat synthetic_events
        myevent     char[16]; str; int v
    
      name: myevent
      ID: 1936
      format:
            field:unsigned short common_type;       offset:0;       size:2; signed:0;
            field:unsigned char common_flags;       offset:2;       size:1; signed:0;
            field:unsigned char common_preempt_count;       offset:3;       size:1; signed:0;
            field:int common_pid;   offset:4;       size:4; signed:1;
    
            field:char str[16];;    offset:8;       size:16;        signed:1;
            field:int v;    offset:40;      size:4; signed:1;
    
      print fmt: "str=%s, v=%d", REC->str, REC->v
    
    After:
    
      # echo 'myevent char str[16]; int v' >> synthetic_events
      # cat synthetic_events
        myevent     char[16] str; int v
    
      # cat events/synthetic/myevent/format
      name: myevent
      ID: 1936
      format:
            field:unsigned short common_type;       offset:0;       size:2; signed:0;
            field:unsigned char common_flags;       offset:2;       size:1; signed:0;
            field:unsigned char common_preempt_count;       offset:3;       size:1; signed:0;
            field:int common_pid;   offset:4;       size:4; signed:1;
    
            field:char str[16];     offset:8;       size:16;        signed:1;
            field:int v;    offset:40;      size:4; signed:1;
    
      print fmt: "str=%s, v=%d", REC->str, REC->v
    
    Link: https://lkml.kernel.org/r/6587663b56c2d45ab9d8c8472a2110713cdec97d.1602598160.git.zanussi@xxxxxxxxxx
    
    [ <rostedt@xxxxxxxxxxx>: wrote parse_synth_field() snippet. ]
    Fixes: 4b147936fa50 (tracing: Add support for 'synthetic' events)
    Reported-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Tested-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Signed-off-by: Tom Zanussi <zanussi@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 46a96686e93c6..c8892156db341 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -132,7 +132,7 @@ static int synth_field_string_size(char *type)
 	start += sizeof("char[") - 1;
 
 	end = strchr(type, ']');
-	if (!end || end < start)
+	if (!end || end < start || type + strlen(type) > end + 1)
 		return -EINVAL;
 
 	len = end - start;
@@ -502,8 +502,14 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
 	if (field_type[0] == ';')
 		field_type++;
 	len = strlen(field_type) + 1;
-	if (array)
-		len += strlen(array);
+
+        if (array) {
+                int l = strlen(array);
+
+                if (l && array[l - 1] == ';')
+                        l--;
+                len += l;
+        }
 	if (prefix)
 		len += strlen(prefix);
 



[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