git: c23da668fa8e - main - vmm: Be more consistent with the credential used for VM lookup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Aug 2024 19:12:45 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=c23da668fa8e341c6f51d70ec632de617b693215
commit c23da668fa8e341c6f51d70ec632de617b693215
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-08-28 18:57:33 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-08-28 18:57:33 +0000
vmm: Be more consistent with the credential used for VM lookup
vmmdev_lookup() is used from sysctl context to find a VM by name.
There, a reference credential is already passed, so use that instead of
assuming that it's the same as curthread->td_ucred, even though that's
true today. No functional change intended.
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D46447
---
sys/dev/vmm/vmm_dev.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sys/dev/vmm/vmm_dev.c b/sys/dev/vmm/vmm_dev.c
index c42b2aaee5ed..53b4dc8cda91 100644
--- a/sys/dev/vmm/vmm_dev.c
+++ b/sys/dev/vmm/vmm_dev.c
@@ -152,7 +152,7 @@ vcpu_unlock_all(struct vmmdev_softc *sc)
}
static struct vmmdev_softc *
-vmmdev_lookup(const char *name)
+vmmdev_lookup(const char *name, struct ucred *cred)
{
struct vmmdev_softc *sc;
@@ -166,7 +166,7 @@ vmmdev_lookup(const char *name)
if (sc == NULL)
return (NULL);
- if (cr_cansee(curthread->td_ucred, sc->ucred))
+ if (cr_cansee(cred, sc->ucred))
return (NULL);
return (sc);
@@ -786,7 +786,7 @@ vmmdev_lookup_and_destroy(const char *name, struct ucred *cred)
struct vmmdev_softc *sc;
mtx_lock(&vmmdev_mtx);
- sc = vmmdev_lookup(name);
+ sc = vmmdev_lookup(name, cred);
if (sc == NULL || sc->cdev == NULL) {
mtx_unlock(&vmmdev_mtx);
return (EINVAL);
@@ -860,7 +860,7 @@ vmmdev_create(const char *name, struct ucred *cred)
int error;
mtx_lock(&vmmdev_mtx);
- sc = vmmdev_lookup(name);
+ sc = vmmdev_lookup(name, cred);
mtx_unlock(&vmmdev_mtx);
if (sc != NULL)
return (EEXIST);
@@ -876,7 +876,7 @@ vmmdev_create(const char *name, struct ucred *cred)
* dropped the lock.
*/
mtx_lock(&vmmdev_mtx);
- sc2 = vmmdev_lookup(name);
+ sc2 = vmmdev_lookup(name, cred);
if (sc2 != NULL) {
mtx_unlock(&vmmdev_mtx);
vmmdev_destroy(sc);