From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10629357D11; Wed, 30 Sep 2026 16:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786917; cv=none; b=XLEhmRjlK9kzWRb0tTaOz/wthkgEXGSxvBbeyxVENyq3F55HB0qoy5lbODjjUMtgP4kJ++eKx/jMRaizUEncYxDzpO54pRGb4aQXmzzZ7UXR3ZaREx0uPxB0N50whH7OTP2QDMmWzX+Y6ky0if/xvqc1OiqVEQDODrMlXygb3nw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786917; c=relaxed/simple; bh=tL8GCIqWN/ft7RsmRvJf5leU5sOcz8+34SbIhX/IouA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tm0vJRNFKSvCAwlCFVHgFlZyWYm26NVlmsGUP0ZxMpjgbla6ncj+fIRjQTNyFc72IdXkcjxfD+S4DCg5tR0WsbWpqbXxWY3r18UHsz91x8MSdz4yqrh3S0cbHw4lkRhgxxJ2Yj8uXLJlM9zaemkvcS4VBe+ey9IXKdHXCXmS+ds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rw8WyGC9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rw8WyGC9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EA7D1F000FF; Wed, 30 Sep 2026 16:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786916; bh=ftbRe8aT5y7AB0nq+UG5upGlHxHdW5/V9miZwYc7sJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rw8WyGC9rDOFv8YZ80H24zW2U+3HmeKloptgj91MMA4uHKVVABKAplN0hKm7mMJMR rvdpw4gw9Na8Yc5TpE86koFXQwDcJGhGvJhBPGvsVLgu0z/iuK35UmonFu3GH+KBGB SMmTTIIFJau5Fyc3CO/O+FOUKu4h+ckKbR6shC9U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karl Mehltretter , Steffen Eiden , Fuad Tabba , Oliver Upton , Sasha Levin Subject: [PATCH 7.2 046/457] KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0 Date: Wed, 30 Sep 2026 17:22:31 +0200 Message-ID: <20260930152347.029236546@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152346.024115587@linuxfoundation.org> References: <20260930152346.024115587@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter [ Upstream commit 64dc6f1db7e620f2e9337bb181f305fb0561da79 ] kvm_smccc_set_filter() only rejects a range if its inclusive end, base + nr_functions - 1, is below base. That catches an empty range (nr_functions == 0) at every nonzero base, but at base 0 the end wraps to U32_MAX and KVM tries to insert [0, U32_MAX], which overlaps the reserved Arm Architecture Calls ranges. KVM_ARM_VM_SMCCC_FILTER then returns -EEXIST instead of the -EINVAL that the smccc_filter selftest expects for an empty range. Reject a zero function count explicitly. Tested with a userspace reproducer on an arm64 VHE host under QEMU TCG: EEXIST before, EINVAL after. Fixes: 821d935c87bc ("KVM: arm64: Introduce support for userspace SMCCC filtering") Assisted-by: LLM Signed-off-by: Karl Mehltretter Reviewed-by: Steffen Eiden Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Link: https://patch.msgid.link/20260829054856.70549-2-kmehltretter@gmail.com Signed-off-by: Oliver Upton Signed-off-by: Sasha Levin --- arch/arm64/kvm/hypercalls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index b11b8821c9fbc..dfa25bb6f25d4 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -185,7 +185,8 @@ static int kvm_smccc_set_filter(struct kvm *kvm, struct kvm_smccc_filter __user start = filter.base; end = start + filter.nr_functions - 1; - if (end < start || filter.action >= NR_SMCCC_FILTER_ACTIONS) + if (!filter.nr_functions || end < start || + filter.action >= NR_SMCCC_FILTER_ACTIONS) return -EINVAL; mutex_lock(&kvm->arch.config_lock); -- 2.53.0