From nobody Sun Oct 6 15:01:46 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XM58q11rzz5YBFh; Sun, 06 Oct 2024 15:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XM58p74Gpz487v; Sun, 6 Oct 2024 15:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728226907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jU5eNg8LDnGs7hfLS3P+FdmmyP9qxf+fY0chGH0iCjk=; b=Nd6CZUWw4h7k1z1stYV+6rkjfXBRGO6zvRBjl5BRM0UNNbzjzSiS6Fqxv1n3/UNHAqJsMQ M+vt1YDLr5EWv8Q6FhJWEdyhJQ+QHF/RfDC5pCIjfidBogqpQwajWYDzefDBTSmJH/kX4M a2fht/DdQQ8XwfhDrd0fIJBdh34np6xXJRUHhdhl2J6kQc4hnt2348uKXFQ92R69LC1fZz LfnqMDctw+HfByROs7j6c1GrRy4nGWNEX5GP2pqsFg7zLLyGgTHn1n1lCYOVkIYAFLxNKt CYS/VrC574PLcFgGLz0zdb2jPKlP6pyCjnW08TZ9Q872uS6tpA8fD4w4r+NQxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728226907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jU5eNg8LDnGs7hfLS3P+FdmmyP9qxf+fY0chGH0iCjk=; b=VW68SNDwyzxB9lXddMtYRE44sytuZXMDA5QEO5HF6eoNTJDFUeIFoC4IcNSl8y5nb9pPMS mI5hahT2GFXTOq5O/N6NQRUU5UBguVUgElOIWkld4RYFULfHsDEKysA1+AVJs1EWnAqyMs 7+nY7h8EF+szo8zvwxWBExFJiQC0CQLpLfWVbske2bQ6WtCi6HVnzlgS4B6ZeXlxjFy26P WvbVv089mU7YA7vTSSE0l6AYCg1LDQVD5eKExUIBvUQjwz4o+A2ic4uMFOBVBq6AJUq0NB GRJ3kB9J5XpecuFE+ipVtImtBpzVdpEBFK5SCLpyx64Nym2TdDleoOFHJ0vG/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728226907; a=rsa-sha256; cv=none; b=sWsoC5kyft8AZgfY4FAdxFt42hX8KDvJkSLO0t7Rn97yPWNqyLJEidcozpEb3M7IgrN7hc XPCpZUxpo6X5m6JMSg7pZ5nCrQoOixqUYukSk8aHWcGMy4F56L+6wbPB+BW6fnrVZSShpQ dy+jnPpybaqRc92hRFzdQLNt086sFSgcxXI+E2w6q10YeFuV/WvhsPl93UUh196kK9SZ5V zFsQenq4cypOIMaigu8fvsFZydTdyHdJrFpAmpOy7cv6C7Nhz1ZFaY/I3jSMlstEjdbFB7 43I/RAff5dF+GaPaZhklTbAKQDQR1nKu5ct3ymudbFqWCCd7sNUqG8qLqDXuvQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XM58p6hNLz16JZ; Sun, 6 Oct 2024 15:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 496F1k8J046930; Sun, 6 Oct 2024 15:01:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 496F1k0Q046927; Sun, 6 Oct 2024 15:01:46 GMT (envelope-from git) Date: Sun, 6 Oct 2024 15:01:46 GMT Message-Id: <202410061501.496F1k0Q046927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: f8db6fb90e73 - stable/14 - vmm: avoid potential KASSERT kernel panic in vm_handle_db List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f8db6fb90e739293d6d72310fa554ede072f8232 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=f8db6fb90e739293d6d72310fa554ede072f8232 commit f8db6fb90e739293d6d72310fa554ede072f8232 Author: Pierre Pronchery AuthorDate: 2024-07-25 14:40:35 +0000 Commit: Ed Maste CommitDate: 2024-10-06 15:01:24 +0000 vmm: avoid potential KASSERT kernel panic in vm_handle_db If the guest VM emits the exit code VM_EXITCODE_DB the kernel will execute the function named vm_handle_db. If the value of rsp is not page aligned and if rsp+sizeof(uint64_t) spans across two pages, the function vm_copy_setup will need two structs vm_copyinfo to prepare the copy operation. For instance is rsp value is 0xFFC, two vm_copyinfo objects are needed: * address=0xFFC, len=4 * address=0x1000, len=4 The vulnerability was addressed by commit 51fda658baa ("vmm: Properly handle writes spanning across two pages in vm_handle_db"). Still, replace the KASSERT with an error return as a more defensive approach. Reported by: Synacktiv Reviewed by markj, emaste Security: HYP-09 Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46133 (cherry picked from commit d19fa9c1b72bc52e51524abcc59ad844012ec365) --- sys/amd64/vmm/vmm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index ef4c7a9af2ea..677dcd05b9b2 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -2786,7 +2786,8 @@ vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging, nused = 0; remaining = len; while (remaining > 0) { - KASSERT(nused < num_copyinfo, ("insufficient vm_copyinfo")); + if (nused >= num_copyinfo) + return (EFAULT); error = vm_gla2gpa(vcpu, paging, gla, prot, &gpa, fault); if (error || *fault) return (error);