]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
perf/x86/intel/uncore: Fix integer overflow on 23 bit left shift of a u32
authorColin Ian King <colin.king@canonical.com>
Tue, 6 Jul 2021 11:45:53 +0000 (12:45 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 24 Sep 2021 09:58:35 +0000 (11:58 +0200)
commit79a593ef148ad63fcc021346505e010f4cdd0aa1
tree7e43794a9d20dec00818ba9f8cfe5348c7e9811a
parent171c79c7eb3709b050d8189f6702a1f6db2c99eb
perf/x86/intel/uncore: Fix integer overflow on 23 bit left shift of a u32

BugLink: https://bugs.launchpad.net/bugs/1944610
[ Upstream commit 0b3a8738b76fe2087f7bc2bd59f4c78504c79180 ]

The u32 variable pci_dword is being masked with 0x1fffffff and then left
shifted 23 places. The shift is a u32 operation,so a value of 0x200 or
more in pci_dword will overflow the u32 and only the bottow 32 bits
are assigned to addr. I don't believe this was the original intent.
Fix this by casting pci_dword to a resource_size_t to ensure no
overflow occurs.

Note that the mask and 12 bit left shift operation does not need this
because the mask SNR_IMC_MMIO_MEM0_MASK and shift is always a 32 bit
value.

Fixes: ee49532b38dd ("perf/x86/intel/uncore: Add IMC uncore support for Snow Ridge")
Addresses-Coverity: ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20210706114553.28249-1-colin.king@canonical.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/events/intel/uncore_snbep.c