diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-11 23:26:09 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-11 23:26:09 +0000 |
commit | a5626338bf8e77f01adc5e828471077e546b7ff8 (patch) | |
tree | 7ce29149950279f1aa4da97cdb0af07cc84163a7 /sys/scsi/scsi_ioctl.c | |
parent | 95d95400508740acc4f2cf1907793208f8c9692c (diff) |
limit ioctl priviledges
Diffstat (limited to 'sys/scsi/scsi_ioctl.c')
-rw-r--r-- | sys/scsi/scsi_ioctl.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/sys/scsi/scsi_ioctl.c b/sys/scsi/scsi_ioctl.c index c11dfba368b..d21f7ac77fb 100644 --- a/sys/scsi/scsi_ioctl.c +++ b/sys/scsi/scsi_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_ioctl.c,v 1.4 1996/06/17 05:16:44 downsj Exp $ */ +/* $OpenBSD: scsi_ioctl.c,v 1.5 1996/08/11 23:26:03 deraadt Exp $ */ /* $NetBSD: scsi_ioctl.c,v 1.20 1996/02/14 21:47:22 christos Exp $ */ /* @@ -333,6 +333,8 @@ scsi_do_ioctl(sc_link, dev, cmd, addr, flag, p) case SCIOCDEBUG: { int level = *((int *)addr); + if ((flag & FWRITE) == 0) + return EBADF; SC_DEBUG(sc_link, SDEV_DB3, ("debug set to %d\n", level)); sc_link->flags &= ~SDEV_DBX; /* clear debug bits */ if (level & 1) @@ -348,29 +350,52 @@ scsi_do_ioctl(sc_link, dev, cmd, addr, flag, p) case SCIOCREPROBE: { struct scsi_addr *sca = (struct scsi_addr *)addr; + if ((flag & FWRITE) == 0) + return EBADF; return scsi_probe_busses(sca->scbus, sca->target, sca->lun); } case SCIOCRECONFIG: case SCIOCDECONFIG: return EINVAL; - case SCIOCIDENTIFY: { - struct scsi_addr *sca = (struct scsi_addr *)addr; - - sca->scbus = sc_link->scsibus; - sca->target = sc_link->target; - sca->lun = sc_link->lun; - return 0; - } case SCIOCRESET: { + if ((flag & FWRITE) == 0) + return EBADF; scsi_scsi_cmd(sc_link, 0, 0, 0, 0, GENRETRY, 2000, NULL, SCSI_RESET); return 0; } default: - return ENOTTY; + return scsi_do_safeioctl(sc_link, dev, cmd, addr, flag, p); } #ifdef DIAGNOSTIC panic("scsi_do_ioctl: impossible"); #endif } + +int +scsi_do_safeioctl(sc_link, dev, cmd, addr, flag, p) + struct scsi_link *sc_link; + dev_t dev; + u_long cmd; + caddr_t addr; + int flag; + struct proc *p; +{ + int error; + + SC_DEBUG(sc_link, SDEV_DB2, ("scsi_do_ioctl(0x%lx)\n", cmd)); + + switch(cmd) { + case SCIOCIDENTIFY: { + struct scsi_addr *sca = (struct scsi_addr *)addr; + + sca->scbus = sc_link->scsibus; + sca->target = sc_link->target; + sca->lun = sc_link->lun; + return 0; + } + default: + return ENOTTY; + } +} |