commit | c717c93131b1b6e3705a11092a70ac47c78b731d | [log] [tgz] |
---|---|---|
author | Daniele Di Proietto <ddiproietto@google.com> | Thu Dec 02 15:17:17 2021 +0000 |
committer | Daniele Di Proietto <ddiproietto@google.com> | Mon Dec 06 09:53:55 2021 +0000 |
tree | ac3ac3e0e62e7df44d232b91a7e95ced2c8248d6 | |
parent | c949b5f8e83df73166dd8c9eb5edffba93e02992 [diff] |
Accept non zero-terminated strings in ftrace fields ReadIntoString() fails if strings are not null terminated. There are three cases in which ReadIntoString() is called: 1. For fixed fields declared as: ``` field:char newcomm[16]; offset:28; size:16; signed:1; ``` the max length of the string is bounded by the fixed size. 2. For variable length fields declared at the end of an event: ``` field:char buf[]; offset:16; size:0; signed:1; ``` the max length of the buffer is bounded by the event size. 3. For __data_loc fields: ``` field:__data_loc char[] name; offset:16; size:4; signed:1; ``` each field has an offset and a size. The max length of the string is bounded by the fixed size. In some rare cases, e.g., if this kernel commit is missing: `f0a515780393("tracing: Don't make assumptions about length of string on task rename")` the kernel can output a buffer that's not zero-terminated (e.g. for case 1) In all cases, the string size is limited explicitly. The code should still stop copying when it finds the '\0' terminator, but, if it doesn't find that, it could still copy what's there. There's no risk of going out of bounds, so this commit stops complaining (and eventually hitting a PERFETTO_CHECK), if strings are not null terminated. Bug: 205763418 Change-Id: I2159ecbc4dd42d31f54613efa5e77c9d7eca09fb
Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.
See https://perfetto.dev/docs or the /docs/ directory for documentation.