Subject: Re: CVS commit: src/sys/secmodel/bsd44
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Elad Efrat <elad@NetBSD.org>
List: tech-kern
Date: 11/04/2006 13:10:29
This is a multi-part message in MIME format.
--Boundary_(ID_LwUpF2qk1nZ7ytjBPRaiBg)
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
obvious change after previous, attached is a diff to replace securelevel
references in various device drivers with kauth calls.
I think they're correct, but please review at least the tc/stic.c one.
-e.
--
Elad Efrat
--Boundary_(ID_LwUpF2qk1nZ7ytjBPRaiBg)
Content-type: text/plain; name=passthru.diff
Content-transfer-encoding: 7BIT
Content-disposition: inline; filename=passthru.diff
Index: i2o/dpti.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2o/dpti.c,v
retrieving revision 1.28
diff -u -p -r1.28 dpti.c
--- i2o/dpti.c 12 Oct 2006 01:30:58 -0000 1.28
+++ i2o/dpti.c 4 Nov 2006 11:07:32 -0000
@@ -78,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: dpti.c,v 1.2
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -276,7 +277,8 @@ dptiioctl(dev_t dev, u_long cmd, caddr_t
break;
case DPT_I2OUSRCMD:
- if (securelevel > 1) {
+ if (kauth_authorize_device_passthru(l->l_cred, dev,
+ data) != 0) {
rv = EPERM;
break;
}
Index: i2o/iop.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2o/iop.c,v
retrieving revision 1.59
diff -u -p -r1.59 iop.c
--- i2o/iop.c 12 Oct 2006 01:30:58 -0000 1.59
+++ i2o/iop.c 4 Nov 2006 11:07:37 -0000
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.59
#include <sys/endian.h>
#include <sys/conf.h>
#include <sys/kthread.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -2525,7 +2526,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t
switch (cmd) {
case IOPIOCPT:
- if (securelevel >= 2)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
return (iop_passthrough(sc, (struct ioppt *)data, l->l_proc));
Index: ic/dpt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/dpt.c,v
retrieving revision 1.52
diff -u -p -r1.52 dpt.c
--- ic/dpt.c 12 Oct 2006 01:31:00 -0000 1.52
+++ ic/dpt.c 4 Nov 2006 11:07:39 -0000
@@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.52
#include <sys/buf.h>
#include <sys/endian.h>
#include <sys/conf.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -1154,7 +1155,7 @@ dptioctl(dev_t dev, u_long cmd, caddr_t
break;
case DPT_EATAUSRCMD:
- if (securelevel > 1)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
if (IOCPARM_LEN(cmd) < sizeof(struct eata_ucp)) {
Index: ic/icp_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/icp_ioctl.c,v
retrieving revision 1.11
diff -u -p -r1.11 icp_ioctl.c
--- ic/icp_ioctl.c 12 Oct 2006 01:31:00 -0000 1.11
+++ ic/icp_ioctl.c 4 Nov 2006 11:07:39 -0000
@@ -85,6 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: icp_ioctl.c,
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
+#include <sys/kauth.h>
#include <machine/bus.h>
@@ -120,7 +121,7 @@ icpopen(dev_t dev, int flag __unused, in
static int
icpioctl(dev_t dev, u_long cmd, caddr_t data, int flag __unused,
- struct lwp *l __unused)
+ struct lwp *l)
{
int error;
@@ -133,7 +134,7 @@ icpioctl(dev_t dev, u_long cmd, caddr_t
struct icp_softc *icp;
gdt_ucmd_t *ucmd = (void *) data;
- if (securelevel > 1)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
icp = device_lookup(&icp_cd, ucmd->io_node);
Index: ic/mlx.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/mlx.c,v
retrieving revision 1.46
diff -u -p -r1.46 mlx.c
--- ic/mlx.c 12 Oct 2006 01:31:01 -0000 1.46
+++ ic/mlx.c 4 Nov 2006 11:07:44 -0000
@@ -91,6 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.46
#include <sys/conf.h>
#include <sys/kthread.h>
#include <sys/disk.h>
+#include <sys/kauth.h>
#include <machine/vmparam.h>
#include <machine/bus.h>
@@ -797,7 +798,7 @@ mlxioctl(dev_t dev, u_long cmd, caddr_t
return (0);
case MLX_COMMAND:
- if (securelevel >= 2)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
/*
Index: pci/amr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/amr.c,v
retrieving revision 1.39
diff -u -p -r1.39 amr.c
--- pci/amr.c 12 Oct 2006 01:31:28 -0000 1.39
+++ pci/amr.c 4 Nov 2006 11:07:46 -0000
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.39
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/kthread.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -1356,7 +1357,7 @@ amrclose(dev_t dev, int flag __unused, i
static int
amrioctl(dev_t dev, u_long cmd, caddr_t data, int flag __unused,
- struct lwp *l __unused)
+ struct lwp *l)
{
struct amr_softc *amr;
struct amr_user_ioctl *au;
@@ -1376,7 +1377,7 @@ amrioctl(dev_t dev, u_long cmd, caddr_t
*(int *)data = AMR_IO_VERSION_NUMBER;
return 0;
case AMR_IO_COMMAND:
- if (securelevel >= 2)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
au = (struct amr_user_ioctl *)data;
Index: pci/mly.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/mly.c,v
retrieving revision 1.30
diff -u -p -r1.30 mly.c
--- pci/mly.c 12 Oct 2006 01:31:32 -0000 1.30
+++ pci/mly.c 4 Nov 2006 11:07:49 -0000
@@ -91,6 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: mly.c,v 1.30
#include <sys/ioctl.h>
#include <sys/scsiio.h>
#include <sys/kthread.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -2308,7 +2309,7 @@ mlyclose(dev_t dev, int flag __unused, i
*/
int
mlyioctl(dev_t dev, u_long cmd, caddr_t data, int flag __unused,
- struct lwp *l __unused)
+ struct lwp *l)
{
struct mly_softc *mly;
int rv;
@@ -2317,7 +2318,7 @@ mlyioctl(dev_t dev, u_long cmd, caddr_t
switch (cmd) {
case MLYIO_COMMAND:
- if (securelevel >= 2)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
rv = EPERM;
else
rv = mly_user_command(mly, (void *)data);
Index: pci/twe.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/twe.c,v
retrieving revision 1.79
diff -u -p -r1.79 twe.c
--- pci/twe.c 12 Oct 2006 01:31:33 -0000 1.79
+++ pci/twe.c 4 Nov 2006 11:07:52 -0000
@@ -85,6 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: twe.c,v 1.79
#include <sys/disk.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -1752,7 +1753,7 @@ twe_ccb_wait_handler(struct twe_ccb *ccb
*/
static int
tweioctl(dev_t dev, u_long cmd, caddr_t data, int flag __unused,
- struct lwp *l __unused)
+ struct lwp *l)
{
struct twe_softc *twe;
struct twe_ccb *ccb;
@@ -1772,7 +1773,7 @@ tweioctl(dev_t dev, u_long cmd, caddr_t
/* This is intended to be compatible with the FreeBSD interface. */
switch (cmd) {
case TWEIO_COMMAND:
- if (securelevel >= 2)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, data) != 0)
return (EPERM);
/* XXX mutex */
Index: tc/stic.c
===================================================================
RCS file: /cvsroot/src/sys/dev/tc/stic.c,v
retrieving revision 1.34
diff -u -p -r1.34 stic.c
--- tc/stic.c 23 Aug 2006 15:44:30 -0000 1.34
+++ tc/stic.c 4 Nov 2006 11:08:06 -0000
@@ -84,6 +84,7 @@ __KERNEL_RCSID(0, "$NetBSD: stic.c,v 1.3
#include <sys/ioctl.h>
#include <sys/callout.h>
#include <sys/conf.h>
+#include <sys/kauth.h>
#include <uvm/uvm_extern.h>
@@ -1458,7 +1459,7 @@ sticopen(dev_t dev, int flag, int mode,
struct stic_info *si;
int s;
- if (securelevel > 0)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, NULL) != 0)
return (EPERM);
if (minor(dev) >= STIC_MAXDV)
return (ENXIO);
@@ -1497,7 +1498,7 @@ sticmmap(dev_t dev, off_t offset, int pr
struct stic_xmap *sxm;
paddr_t pa;
- if (securelevel > 0)
+ if (kauth_authorize_device_passthru(l->l_cred, dev, NULL) != 0)
return (-1L);
si = stic_info[minor(dev)];
--Boundary_(ID_LwUpF2qk1nZ7ytjBPRaiBg)--