Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:115:29

From: Meelis Roos
Date: Thu May 19 2016 - 03:36:17 EST


> I think UBSAN has correctly identified a bug. I looked at the code in
> v4.6. In file arch/x86/events/core.c, in the function
> filter_events(), there is a loop starting at line 1554 that should go
> over 10 event counters. But in file arch/x86/events/intel/p6.c, only
> 8 event counters have been declared at line 9.
>
> I have a fix but do not for sure if its reasonable. I think we should
> pass on the max_events for the pmu to filter_events() function and
> change the loop condition accordingly. Can you apply the patch below
> and test again? It compiles, but I have not tested it.

Seems to work - warning is gone, everythins is detected as before.

--
Meelis Roos (mroos@xxxxxxxx)