Re: [PATCH v2] perf session: fix decompression of PERF_RECORD_COMPRESSED records

From: Alexey Budankov
Date: Mon Nov 18 2019 - 09:20:37 EST


On 18.11.2019 15:22, Jiri Olsa wrote:
> On Mon, Nov 18, 2019 at 02:30:04PM +0300, Alexey Budankov wrote:
<SNIP>
>>
>> @@ -1971,20 +1971,32 @@ fetch_mmaped_event(struct perf_session *session,
>> return NULL;
>>
>> event = (union perf_event *)(buf + head);
>> + if (needs_swap)
>> + perf_event_header__bswap(&event->header);
>>
>> - if (session->header.needs_swap)
>> + if (head + event->header.size <= mmap_size)
>> + return event;
>> +
>> + /* We're not fetching the event so swap back again */
>> + if (needs_swap)
>> perf_event_header__bswap(&event->header);
>>
>> - if (head + event->header.size > mmap_size) {
>> - /* We're not fetching the event so swap back again */
>> - if (session->header.needs_swap)
>> - perf_event_header__bswap(&event->header);
>> - pr_debug("%s: head=%#" PRIx64 " event->header_size=%#x, mmap_size=%#zx: fuzzed perf.data?\n",
>> - __func__, head, event->header.size, mmap_size);
>> - return ERR_PTR(-EINVAL);
>> - }
>> + pr_debug("%s: head=%#" PRIx64 " event->header_size=%#x, mmap_size=%#zx\n",
>> + __func__, head, event->header.size, mmap_size);
>
> you're missign the 'fuzzed perf.data?' in here
>
> I think we should keep it just change to: 'fuzzed or compressed perf.data?'

Fixed in v3.

>
> thanks,
> jirka

~Alexey