[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <86jzbkp1cc.wl-maz@kernel.org>
Date: Sat, 28 Dec 2024 10:07:47 +0000
From: Marc Zyngier <maz@...nel.org>
To: Steven Davis <goldside000@...look.com>
Cc: "oliver.upton@...ux.dev"
<oliver.upton@...ux.dev>,
"catalin.marinas@....com"
<catalin.marinas@....com>,
"will@...nel.org" <will@...nel.org>,
"joey.gouly@....com" <joey.gouly@....com>,
"suzuki.poulose@....com"
<suzuki.poulose@....com>,
"yuzenghui@...wei.com" <yuzenghui@...wei.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"kvmarm@...ts.linux.dev"
<kvmarm@...ts.linux.dev>,
"linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] arm64: kvm: Fix potential overflow in len
On Sat, 28 Dec 2024 02:01:27 +0000,
Steven Davis <goldside000@...look.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.
Powered by blists - more mailing lists