[PATCH] arm64: kvm: Fix potential overflow in len
Marc Zyngier
maz at kernel.org
Sat Dec 28 02:07:47 PST 2024
On Sat, 28 Dec 2024 02:01:27 +0000,
Steven Davis <goldside000 at outlook.com> wrote:
>
> The MMIO sign-extension logic in kvm_handle_mmio_return can
> trigger an integer overflow or undefined behavior when len
> is invalid (e.g., len == 0 or len exceeds the size of unsigned
> long). Specifically, the expression (len * 8) - 1 may result
> in an out-of-bounds shift in the computation of the mask.
>
> This patch adds validation to ensure len is greater than
> 0 and less than the size of unsigned long before performing
> the sign-extension logic. If len falls outside this range,
> the problematic logic is skipped, preventing potential issues.
I'd be curious to understand how you came to this conclusion, given
how len is computed. If anything, we could *remove* some of the
checks, rather than adding additional ones.
Also, "skipping" things is rarely an acceptable behaviour when
emulating hardware behaviour.
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list