mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 19:53:15 -04:00
The sample parsing test only validates grouped read values when PERF_FORMAT_LOST is present. For PERF_FORMAT_GROUP without PERF_FORMAT_LOST, the contents of read.group.values[] are not validated, allowing corruption of the parsed value and id fields to go undetected. The values are also handed to the synthesis as a plain array of struct sample_read_value, which always has a 24-byte stride, while read.group.values is expected to be packed according to read_format -- evsel__parse_sample() points it into the event data. Without PERF_FORMAT_LOST the stride is 16, so both the synthesis and the comparison walk overlapping bytes and the test passes regardless of the contents. Validate value and id for grouped reads and continue to validate lost when PERF_FORMAT_LOST is present, walking the entries with next_sample_read_value(). Also build the input packed using sample_read_value_size() so the compared fields are the real ones. Verified with a deliberate stride bug in copy_read_group_values(): the test still passes without this change and fails at read_format 0xc with it applied. Signed-off-by: PVS Narasimha Rao <venkatasuryapala@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>