*BSD News Article 62591


Return to BSD News archive

Newsgroups: comp.bugs.2bsd
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!newshost.telstra.net!act.news.telstra.net!psgrain!newsfeed.internetmci.com!news.mathworks.com!uunet!in2.uu.net!news.new-york.net!wlbr!sms
From: sms@wlv.iipo.gtegsc.com (Steven M. Schultz)
Subject: MNT_NODEV was checked in wrong place (#306)
Sender: news@wlbr.iipo.gtegsc.com (System Administrator)
Organization: GTE Government Systems, Thousand Oaks CA USA
Message-ID: <DnMvLI.GA9@wlbr.iipo.gtegsc.com>
X-Nntp-Posting-Host: wlv.iipo.gtegsc.com
Date: Sat, 2 Mar 1996 09:27:17 GMT
Lines: 95

Subject: MNT_NODEV was checked in wrong place (#306)
Index:	sys/sys_inode.c 2.11BSD

Description:
	The kernel check for prohibited special device node access was
	a few lines too high in the source.

Repeat-By:
	mount -o nodev /dev/ram /tmp
	ls /tmp

	/tmp not readable

Fix:
	A brain fade (to be polite) on my part.  The 'openi' routine
	was checking the MNT_NODEV bit too soon - before it was known if
	the inode being opened was a CHR or BLK device.  Oops.

	Cut where indicated saving to a file (/tmp/306) then:

		patch -p0 < /tmp/306

	This time you will likely find it useful to rebuild the kernel
	and reboot the system.

---------------------cut here-------------------
*** /sys/sys/sys_inode.c.old	Fri Dec 29 23:10:37 1995
--- /sys/sys/sys_inode.c	Sat Mar  2 00:45:38 1996
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)sys_inode.c	1.6 (2.11BSD GTE) 1995/12/29
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)sys_inode.c	1.7 (2.11BSD GTE) 1996/3/2
   */
  
  #include "param.h"
***************
*** 611,622 ****
  	dev_t bdev;
  	int error;
  
- 	if (ip->i_fs->fs_flags & MNT_NODEV)
- 		return(ENXIO);
- 
  	switch (ip->i_mode&IFMT) {
  
  	case IFCHR:
  		if ((u_int)maj >= nchrdev)
  			return (ENXIO);
  		if (mode & FWRITE) {
--- 611,621 ----
  	dev_t bdev;
  	int error;
  
  	switch (ip->i_mode&IFMT) {
  
  	case IFCHR:
+ 		if (ip->i_fs->fs_flags & MNT_NODEV)
+ 			return(ENXIO);
  		if ((u_int)maj >= nchrdev)
  			return (ENXIO);
  		if (mode & FWRITE) {
***************
*** 643,648 ****
--- 642,649 ----
  		return ((*cdevsw[maj].d_open)(dev, mode, S_IFCHR));
  
  	case IFBLK:
+ 		if (ip->i_fs->fs_flags & MNT_NODEV)
+ 			return(ENXIO);
  		if ((u_int)maj >= nblkdev)
  			return (ENXIO);
  		/*
*** /VERSION.old	Fri Mar  1 23:19:40 1996
--- /VERSION	Sat Mar  2 01:08:15 1996
***************
*** 1,4 ****
! Current Patch Level: 305
  
  2.11 BSD
  ============
--- 1,4 ----
! Current Patch Level: 306
  
  2.11 BSD
  ============