Check to make sure that this device is opened read-write, not just read

only.  Previously, if the device was chmoded 644, someone could open it
with the O_RDONLY flag and issue any ioctl to the device.

Reviewed by:	imp, gibbs
This commit is contained in:
Kenneth D. Merry 1998-09-16 00:11:53 +00:00
parent 90377c4bc7
commit 66a0780e8e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39317
2 changed files with 14 additions and 2 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cam_xpt.c,v 1.1 1998/09/15 06:33:23 gibbs Exp $
* $Id: cam_xpt.c,v 1.2 1998/09/15 22:05:44 gibbs Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
@ -632,6 +632,12 @@ xptopen(dev_t dev, int flags, int fmt, struct proc *p)
unit = minor(dev) & 0xff;
/*
* Only allow read-write access.
*/
if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0))
return(EPERM);
/*
* We don't allow nonblocking access.
*/

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: scsi_pass.c,v 1.1 1998/09/15 06:36:34 gibbs Exp $
*/
#include <sys/param.h>
@ -389,6 +389,12 @@ passopen(dev_t dev, int flags, int fmt, struct proc *p)
if (softc->flags & PASS_FLAG_INVALID)
return(ENXIO);
/*
* Only allow read-write access.
*/
if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0))
return(EPERM);
/*
* We don't allow nonblocking access.
*/