From 7db1d5d9598a5047cf40b7cd3e796316f31fb862 Mon Sep 17 00:00:00 2001 From: ken Date: Sun, 22 Nov 1998 23:44:47 +0000 Subject: Fix a few problems that Bruce noticed about a month ago, and fix oup one other problem. - Hold onto splsoftcam() in the peripheral driver open routines until we have locked the periph. This eliminates a race condition. - Disallow opening the pass driver when securelevel > 1. - If a user tries to open the pass driver with O_NONBLOCK set, return EINVAL instead of ENODEV. (noticed by gibbs) --- sys/cam/scsi/scsi_cd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sys/cam/scsi/scsi_cd.c') diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index dfe86fc..9c6ddb6 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_cd.c,v 1.7 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_cd.c,v 1.8 1998/10/22 22:16:56 ken Exp $ */ /* * Portions of this driver taken from the original FreeBSD cd driver. @@ -890,15 +890,21 @@ cdopen(dev_t dev, int flags, int fmt, struct proc *p) softc = (struct cd_softc *)periph->softc; + /* + * Grab splsoftcam and hold it until we lock the peripheral. + */ s = splsoftcam(); if (softc->flags & CD_FLAG_INVALID) { splx(s); return(ENXIO); } - splx(s); - if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) + if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) { + splx(s); return (error); + } + + splx(s); if ((softc->flags & CD_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) -- cgit v1.1