Re: [PATCH][next] perf/x86/amd: fix potential integer overflow on shift of a int

From: Kim Phillips
Date: Fri Dec 02 2022 - 14:11:09 EST


On 12/2/22 11:36 AM, Ian Rogers wrote:
On Fri, Dec 2, 2022 at 5:52 AM Colin Ian King <colin.i.king@xxxxxxxxx> wrote:

The left shift of int 32 bit integer constant 1 is evaluated using 32 bit
arithmetic and then passed as a 64 bit function argument. In the case where
i is 32 or more this can lead to an overflow. Avoid this by shifting
using the BIT_ULL macro instead.

Fixes: 471af006a747 ("perf/x86/amd: Constrain Large Increment per Cycle events")
Signed-off-by: Colin Ian King <colin.i.king@xxxxxxxxx>

Acked-by: Ian Rogers <irogers@xxxxxxxxxx>

Acked-by: Kim Phillips <kim.phillips@xxxxxxx>

Thanks,

Kim