]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86/amd: fix potential integer overflow on shift of a int
authorColin Ian King <colin.i.king@gmail.com>
Fri, 2 Dec 2022 13:51:49 +0000 (13:51 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 06:52:47 +0000 (07:52 +0100)
commit2eaa109b845f01c50cecd558ebcdf1e75647c12b
treeefd7f809f69c67dca84685ab1f4056a0714c9eb1
parent4786c4879e190ecb05c815104adca7e488e7befd
perf/x86/amd: fix potential integer overflow on shift of a int

commit 08245672cdc6505550d1a5020603b0a8d4a6dcc7 upstream.

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: dcf8995f1468 ("perf/x86/amd: Constrain Large Increment per Cycle events")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Kim Phillips <kim.phillips@amd.com>
Link: https://lore.kernel.org/r/20221202135149.1797974-1-colin.i.king@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/events/amd/core.c