Remove the iskmemdev() function. Make it the responsibility of the mem.c

drivers to enforce the securelevel checks.
This commit is contained in:
Poul-Henning Kamp 1999-11-07 12:01:32 +00:00
parent f6b7df4bbf
commit be8479a836
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52967
8 changed files with 18 additions and 56 deletions

View File

@ -123,6 +123,11 @@ mmopen(dev, flags, fmt, p)
{
switch (minor(dev)) {
case 0:
case 1:
if (securelevel >= 1)
return (EPERM);
break;
case 32:
#ifdef PERFMON
return perfmon_open(dev, flags, fmt, p);
@ -367,23 +372,6 @@ mmpoll(dev, events, p)
}
}
/*
* Routine that identifies /dev/mem and /dev/kmem.
*
* A minimal stub routine can always return 0.
*/
int
iskmemdev(dev)
dev_t dev;
{
return (((major(dev) == mem_cdevsw.d_maj)
&& (minor(dev) == 0 || minor(dev) == 1))
/* or the osf/1 mem device */
||((major(dev) == 0)
&& (minor(dev) == 0x00200002)));
}
int
iszerodev(dev)
dev_t dev;

View File

@ -111,6 +111,11 @@ mmclose(dev, flags, fmt, p)
struct proc *p;
{
switch (minor(dev)) {
case 0:
case 1:
if (securelevel >= 1)
return (EPERM);
break;
case 14:
curproc->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
break;
@ -527,20 +532,6 @@ mmpoll(dev, events, p)
}
}
/*
* Routine that identifies /dev/mem and /dev/kmem.
*
* A minimal stub routine can always return 0.
*/
int
iskmemdev(dev)
dev_t dev;
{
return ((major(dev) == mem_cdevsw.d_maj)
&& (minor(dev) == 0 || minor(dev) == 1));
}
int
iszerodev(dev)
dev_t dev;

View File

@ -176,7 +176,7 @@ spec_open(ap)
return (EPERM);
/*
* When running in secure mode, do not allow opens
* for writing of /dev/mem, /dev/kmem, or character
* for writing of character
* devices whose corresponding block devices are
* currently mounted.
*/
@ -186,8 +186,6 @@ spec_open(ap)
bvp->v_usecount > 0 &&
(error = vfs_mountedon(bvp)))
return (error);
if (iskmemdev(dev))
return (EPERM);
}
}
if ((dsw->d_flags & D_TYPEMASK) == D_TTY)

View File

@ -111,6 +111,11 @@ mmclose(dev, flags, fmt, p)
struct proc *p;
{
switch (minor(dev)) {
case 0:
case 1:
if (securelevel >= 1)
return (EPERM);
break;
case 14:
curproc->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
break;
@ -527,20 +532,6 @@ mmpoll(dev, events, p)
}
}
/*
* Routine that identifies /dev/mem and /dev/kmem.
*
* A minimal stub routine can always return 0.
*/
int
iskmemdev(dev)
dev_t dev;
{
return ((major(dev) == mem_cdevsw.d_maj)
&& (minor(dev) == 0 || minor(dev) == 1));
}
int
iszerodev(dev)
dev_t dev;

View File

@ -1353,7 +1353,7 @@ devfs_open( struct vop_open_args *ap)
return (EPERM);
/*
* When running in secure mode, do not allow opens
* for writing of /dev/mem, /dev/kmem, or character
* for writing of character
* devices whose corresponding block devices are
* currently mounted.
*/
@ -1363,8 +1363,6 @@ devfs_open( struct vop_open_args *ap)
bvp->v_usecount > 0 &&
(error = vfs_mountedon(bvp)))
return (error);
if (iskmemdev(dev))
return (EPERM);
}
}
if ((dsw->d_flags & D_TYPEMASK) == D_TTY)

View File

@ -176,7 +176,7 @@ spec_open(ap)
return (EPERM);
/*
* When running in secure mode, do not allow opens
* for writing of /dev/mem, /dev/kmem, or character
* for writing of character
* devices whose corresponding block devices are
* currently mounted.
*/
@ -186,8 +186,6 @@ spec_open(ap)
bvp->v_usecount > 0 &&
(error = vfs_mountedon(bvp)))
return (error);
if (iskmemdev(dev))
return (EPERM);
}
}
if ((dsw->d_flags & D_TYPEMASK) == D_TTY)

View File

@ -266,7 +266,6 @@ struct cdevsw *devsw __P((dev_t dev));
int devsw_module_handler __P((struct module *mod, int what, void *arg));
const char *devtoname __P((dev_t dev));
void freedev __P((dev_t dev));
int iskmemdev __P((dev_t dev));
int iszerodev __P((dev_t dev));
dev_t makebdev __P((int maj, int min));
dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7);

View File

@ -266,7 +266,6 @@ struct cdevsw *devsw __P((dev_t dev));
int devsw_module_handler __P((struct module *mod, int what, void *arg));
const char *devtoname __P((dev_t dev));
void freedev __P((dev_t dev));
int iskmemdev __P((dev_t dev));
int iszerodev __P((dev_t dev));
dev_t makebdev __P((int maj, int min));
dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7);