From 955613d62b1740790ccfc84f02f5714ff4a94908 Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 26 Sep 2001 20:08:02 +0000 Subject: [PATCH] o Modify device open access control for /dev/mem and friends to use securelevel_gt() instead of direct securelevel variable checks. Obtained from: TrustedBSD Project --- sys/amd64/amd64/mem.c | 12 ++++++++---- sys/i386/i386/mem.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index 48ecff8a3190..c8fdd2a4f008 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -115,15 +115,19 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td) switch (minor(dev)) { case 0: case 1: - if ((flags & FWRITE) && securelevel > 0) - return (EPERM); + if (flags & FWRITE) { + error = securelevel_gt(td->td_proc->p_ucred, 0); + if (error != 0) + return (error); + } break; case 14: error = suser_td(td); if (error != 0) return (error); - if (securelevel > 0) - return (EPERM); + error = securelevel_gt(td->td_proc->p_ucred, 0); + if (error != 0) + return (error); td->td_frame->tf_eflags |= PSL_IOPL; break; } diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index 48ecff8a3190..c8fdd2a4f008 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -115,15 +115,19 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td) switch (minor(dev)) { case 0: case 1: - if ((flags & FWRITE) && securelevel > 0) - return (EPERM); + if (flags & FWRITE) { + error = securelevel_gt(td->td_proc->p_ucred, 0); + if (error != 0) + return (error); + } break; case 14: error = suser_td(td); if (error != 0) return (error); - if (securelevel > 0) - return (EPERM); + error = securelevel_gt(td->td_proc->p_ucred, 0); + if (error != 0) + return (error); td->td_frame->tf_eflags |= PSL_IOPL; break; }