simplify & fix logic in device/rawio/spec.
This commit is contained in:
parent
66e42f0f77
commit
993da55808
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: secmodel_bsd44_securelevel.c,v 1.11 2006/11/04 09:56:59 elad Exp $ */
|
/* $NetBSD: secmodel_bsd44_securelevel.c,v 1.12 2006/11/06 02:02:18 elad Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
|
* Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44_securelevel.c,v 1.11 2006/11/04 09:56:59 elad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44_securelevel.c,v 1.12 2006/11/06 02:02:18 elad Exp $");
|
||||||
|
|
||||||
#ifdef _KERNEL_OPT
|
#ifdef _KERNEL_OPT
|
||||||
#include "opt_insecure.h"
|
#include "opt_insecure.h"
|
||||||
|
@ -354,12 +354,14 @@ secmodel_bsd44_securelevel_device_cb(kauth_cred_t cred __unused,
|
||||||
case KAUTH_DEVICE_RAWIO_SPEC: {
|
case KAUTH_DEVICE_RAWIO_SPEC: {
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
|
int d_type;
|
||||||
|
|
||||||
vp = arg1;
|
vp = arg1;
|
||||||
|
|
||||||
KASSERT(vp != NULL);
|
KASSERT(vp != NULL);
|
||||||
|
|
||||||
dev = vp->v_un.vu_specinfo->si_rdev;
|
dev = vp->v_un.vu_specinfo->si_rdev;
|
||||||
|
d_type = D_OTHER;
|
||||||
|
|
||||||
/* Handle /dev/mem and /dev/kmem. */
|
/* Handle /dev/mem and /dev/kmem. */
|
||||||
if ((vp->v_type == VCHR) && iskmemdev(dev)) {
|
if ((vp->v_type == VCHR) && iskmemdev(dev)) {
|
||||||
|
@ -394,11 +396,8 @@ secmodel_bsd44_securelevel_device_cb(kauth_cred_t cred __unused,
|
||||||
const struct cdevsw *cdev;
|
const struct cdevsw *cdev;
|
||||||
|
|
||||||
cdev = cdevsw_lookup(dev);
|
cdev = cdevsw_lookup(dev);
|
||||||
if ((cdev == NULL) ||
|
if (cdev != NULL)
|
||||||
(cdev->d_type != D_DISK)) {
|
d_type = cdev->d_type;
|
||||||
result = KAUTH_RESULT_ALLOW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -406,11 +405,8 @@ secmodel_bsd44_securelevel_device_cb(kauth_cred_t cred __unused,
|
||||||
const struct bdevsw *bdev;
|
const struct bdevsw *bdev;
|
||||||
|
|
||||||
bdev = bdevsw_lookup(dev);
|
bdev = bdevsw_lookup(dev);
|
||||||
if ((bdev == NULL) ||
|
if (bdev != NULL)
|
||||||
(bdev->d_type != D_DISK)) {
|
d_type = bdev->d_type;
|
||||||
result = KAUTH_RESULT_ALLOW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -419,6 +415,11 @@ secmodel_bsd44_securelevel_device_cb(kauth_cred_t cred __unused,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d_type != D_DISK) {
|
||||||
|
result = KAUTH_RESULT_ALLOW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (vfs_mountedon(vp) && (securelevel > 0))
|
if (vfs_mountedon(vp) && (securelevel > 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue