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 3D7D73EB10D; Wed, 30 Sep 2026 19:30:10 +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=1790796611; cv=none; b=kTPXKDczso5nlL3C0zTptxkMLFtq2jWWbhtAjYjzZ2qyQaSi6ChCgesbIfojmV3wsJSdHw0WZX6rIx3DD4D+F3XkEvsvNsQNW1XhD2FaHrngI/FvKF16aP5aQjD9vswoGHko/WAQVQI1EaciLaBA7UD37pi+PwAvDoaZZkofJWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790796611; c=relaxed/simple; bh=C2+CwjL5h42vhEkYsPsDVzOgDu1AC7EOJ2RrQX/F9u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nYyK8HGgkL2jw0FchumxvX27k6TAeKkKiJHn1TDGv28zcOg1hTujoHvH1bLmSt87MVSA9uUEk0DGLnAM2fRVoLq8pi01uqAW5wISXXdMoNXDCgrT5XnTV+9YHYVQFJA3ZST0TgwgFJC/Q93NdPhZFjLGcFnzKC2Hy/pkCBIscrU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M4yRBQLG; 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="M4yRBQLG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C3A1F000FF; Wed, 30 Sep 2026 19:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790796610; bh=1YtoARyPk0aK65XXs9JvnYVKbpuC4iNMc4GVKu2zJdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M4yRBQLGpwyyXCd1BISRPwo6M9EIioKwxfYjppYAb57SrEpg0PhuX7Ve9i7i//hyK xy9y/6hqnYCfwi+40YEpEJoW4uza3Bjucf3kHANCj8kz/vDipK/x1tY44cwdzyk4gk HaV5SX6+fuIMAAU3uGqYzmPGkkP6eKcnw2O3tHQU= 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 6.6 0974/1193] KVM: arm64: Return -EINVAL for an empty SMCCC filter range at base 0 Date: Wed, 30 Sep 2026 17:27:38 +0200 Message-ID: <20260930152455.883883530@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@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 6.6-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 7fb4df0456dea..f497a5c0afa77 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -174,7 +174,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