Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Aug 2021 11:42:49 GMT
From:      Ka Ho Ng <khng@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 877ba067c0fb - stable/13 - vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1
Message-ID:  <202108271142.17RBgnWw080187@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by khng:

URL: https://cgit.FreeBSD.org/src/commit/?id=877ba067c0fb8e09ef6a47100817615b648bd5ee

commit 877ba067c0fb8e09ef6a47100817615b648bd5ee
Author:     Ka Ho Ng <khng@FreeBSD.org>
AuthorDate: 2021-08-02 09:54:40 +0000
Commit:     Ka Ho Ng <khng@FreeBSD.org>
CommitDate: 2021-08-27 08:52:49 +0000

    vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1
    
    In hw.vmm.create sysctl handler the maximum length of vm name is
    VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is
    only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to
    allow the length of VM_MAX_NAMELEN for vm name.
    
    Reviewed by:    grehan
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D31372
    
    (cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd)
---
 sys/amd64/vmm/vmm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 5c2a404f45a7..80fcde8d80fa 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -174,7 +174,7 @@ struct vm {
 	struct mem_map	mem_maps[VM_MAX_MEMMAPS]; /* (i) guest address space */
 	struct mem_seg	mem_segs[VM_MAX_MEMSEGS]; /* (o) guest memory regions */
 	struct vmspace	*vmspace;		/* (o) guest's address space */
-	char		name[VM_MAX_NAMELEN];	/* (o) virtual machine name */
+	char		name[VM_MAX_NAMELEN+1];	/* (o) virtual machine name */
 	struct vcpu	vcpu[VM_MAXCPU];	/* (i) guest vcpus */
 	/* The following describe the vm cpu topology */
 	uint16_t	sockets;		/* (o) num of sockets */
@@ -480,7 +480,8 @@ vm_create(const char *name, struct vm **retvm)
 	if (!vmm_initialized)
 		return (ENXIO);
 
-	if (name == NULL || strlen(name) >= VM_MAX_NAMELEN)
+	if (name == NULL || strnlen(name, VM_MAX_NAMELEN + 1) ==
+	    VM_MAX_NAMELEN + 1)
 		return (EINVAL);
 
 	vmspace = vmmops_vmspace_alloc(0, VM_MAXUSER_ADDRESS_LA48);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108271142.17RBgnWw080187>