On 6/8/22 10:01, Stephane Eranian via perfmon2-devel wrote:
> Hi,
> 
> Could you try the attached patch?
> There is no use after free in the code as far as I can tell.
> But I modified the code to avoid triggering the gcc warning.
> I don't have gcc-12 so let me know if this works for you.

Hi,

I tried out the patch on Fedora rawhide which has gcc-12 with a rpmbuild of a 
git libpfm repo tarball.  With the patch it builds successfully. Without the 
patch the build failed.  Took a look at the patch and it looks reasonable.

Thanks,

-will
> 
> 
> On Tue, Jun 7, 2022 at 1:26 AM Stephane Eranian <eran...@googlemail.com> 
> wrote:
>>
>> Hi,
>>
>> Thanks for the report,
>>
>> I will fix this in the coming days.
>>
>> On Sat, Jun 4, 2022 at 10:08 AM Vitaly Chikunov <v...@altlinux.org> wrote:
>>>
>>> Stephane,
>>>
>>> There is compile failure on GCC 12.1.1:
>>>
>>>   pfmlib_perf_event_pmu.c: In function 'perf_table_alloc_event':
>>>   pfmlib_perf_event_pmu.c:293:47: error: pointer may be used after 
>>> 'realloc' [-Werror=use-after-free]
>>>     293 |         perf_pe_free = new_pe + (perf_pe_free - perf_pe);
>>>         |                                               ^
>>>   pfmlib_perf_event_pmu.c:289:18: note: call to 'realloc' here
>>>     289 |         new_pe = realloc(perf_pe, perf_pe_count * 
>>> sizeof(perf_event_t));
>>>         |                  
>>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>   In function 'perf_table_alloc_umask',
>>>       inlined from 'gen_tracepoint_table' at pfmlib_perf_event_pmu.c:457:10:
>>>   pfmlib_perf_event_pmu.c:329:47: error: pointer may be used after 
>>> 'realloc' [-Werror=use-after-free]
>>>     329 |         perf_um_free = new_um + (perf_um_free - perf_um);
>>>         |                                               ^
>>>   pfmlib_perf_event_pmu.c:325:18: note: call to 'realloc' here
>>>     325 |         new_um = realloc(perf_um, perf_um_count * 
>>> sizeof(*new_um));
>>>         |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>   cc1: all warnings being treated as errors
>>>
>>> Also, pointer arithmetic on unallocated region are, perhaps, undefined
>>> behavior by C standard. So even though this math looks safe on x86 this
>>> should be fixed anyway to be more portable.
>>>
>>> Thanks,
>>>
>>>
>>>
>>> _______________________________________________
>>> perfmon2-devel mailing list
>>> perfmon2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/perfmon2-devel



_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to