pm-graph v5.10 regression fix
Todd Brandt
maintainerPATCH v2 1/1 pm-graph v5.10 regression fix
A regression has occurred in the hid-sensor code where a device name string has not been initialized to 0, and ends up without a NULL char and its printed with %s. This includes random binary data in the device name, which makes its way into the ftrace output and ends up crashing sleepgraph because it expects the ftrace output to be ASCII only.
For example: "HID-SENSOR-INT-020b?.39.auto" ends up in ftrace instead of "HID-SENSOR-INT-020b.39.auto". It causes this crash in sleepgraph:
File "/usr/bin/sleepgraph", line 5579, in executeSuspend
for line in fp:
File "/usr/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 1568: invalid start byte
The issue is in 6.3-rc1 and is decribed in full here:
https://bugzilla.kernel.org/show_bug.cgi?id=217169
I've submitted a separate fix to have this issue repaired, but it has also exposed a larger bug in sleepgraph, since nothing should make sleepgraph crash. Sleepgraph needs to be able to handle biary data showing up in ftrace gracefully.
I've changed the ftrace processing code to treat it as potentially binary and to filter out binary data and leave just the ASCII.
--- tools/power/pm-graph/sleepgraph.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/power/pm-graph/sleepgraph.py +2 -3
@@ -5556,9 +5556,8 @@ def executeSuspend(quiet=False): if not quiet: pprint('CAPTURING TRACE') op = sv.writeDatafileHeader(sv.ftracefile, testdata) - fp = open(tp+'trace', 'r') - for line in fp: - op.write(line) + fp = open(tp+'trace', 'rb') + op.write(ascii(fp.read())) op.close() sv.fsetVal('', 'trace') sv.platforminfo(cmdafter)
Signature · 1 line
2.34.1
Quoted 21 lines · Todd Brandt
A regression has occurred in the hid-sensor code where a device name string has not been initialized to 0, and ends up without a NULL char and its printed with %s. This includes random binary data in the device name, which makes its way into the ftrace output and ends up crashing sleepgraph because it expects the ftrace output to be ASCII only.
For example: "HID-SENSOR-INT-020b?.39.auto" ends up in ftrace instead of "HID-SENSOR-INT-020b.39.auto". It causes this crash in sleepgraph:
File "
/usr/bin/sleepgraph", line 5579, in executeSuspend
for line in fp:
File "/usr/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) =self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte0xffin position 1568: invalid start byteThe issue is in 6.3-rc1 and is decribed in full here:
https://bugzilla.kernel.org/show_bug.cgi?id=217169
Quoted 7 lines
I've submitted a separate fix to have this issue repaired, but it has also exposed a larger bug in sleepgraph, since nothing should make sleepgraph crash. Sleepgraph needs to be able to handle biary data showing up in ftrace gracefully.
I've changed the ftrace processing code to treat it as potentially binary and to filter out binary data and leave just the ASCII.
Thanks a lot for the detailed description of the problem, it helps quite a bit.
I've modified the subject and changelog somewhat and applied this as 6.3-rc material, thanks!
Quoted 22 lines
Signed-off-by Todd Brandt <[email protected]>--- tools/power/pm-graph/sleepgraph.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)tools/power/pm-graph/sleepgraph.py +2
-4@@ -5556,9 +5556,8 @@ def executeSuspend(quiet=False): if not quiet: pprint('CAPTURING TRACE') op = sv.writeDatafileHeader(sv.ftracefile, testdata) - fp = open(tp+'trace', 'r') - for line in fp: - op.write(line) + fp = open(tp+'trace', 'rb') + op.write(ascii(fp.read())) op.close() sv.fsetVal('', 'trace') sv.platforminfo(cmdafter) --