From 12c79eb288d23bb81176fe61cad1b7a9ee4b9948 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Wed, 3 Apr 2002 10:56:59 +0000 Subject: [PATCH] Dike out a highly insecure UCONSOLE option. TIOCCONS must be able to VOP_ACCESS() /dev/console to succeed. Obtained from: OpenBSD --- sys/alpha/conf/GENERIC | 1 - sys/alpha/conf/NOTES | 1 - sys/alpha/conf/SIMOS | 1 - sys/amd64/conf/GENERIC | 1 - sys/conf/NOTES | 4 ---- sys/conf/options | 1 - sys/i386/conf/GENERIC | 1 - sys/i386/conf/NEWCARD | 1 - sys/i386/conf/NOTES | 4 ---- sys/ia64/conf/GENERIC | 1 - sys/ia64/conf/SKI | 1 - sys/kern/tty.c | 18 ++++++++++++++---- sys/pc98/conf/GENERIC | 1 - sys/sparc64/conf/GENERIC | 1 - 14 files changed, 14 insertions(+), 23 deletions(-) diff --git a/sys/alpha/conf/GENERIC b/sys/alpha/conf/GENERIC index 75bb9c1c9ef0..a6d61c8d12d5 100644 --- a/sys/alpha/conf/GENERIC +++ b/sys/alpha/conf/GENERIC @@ -63,7 +63,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console options KTRACE #ktrace(1) syscall trace support options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues diff --git a/sys/alpha/conf/NOTES b/sys/alpha/conf/NOTES index 75bb9c1c9ef0..a6d61c8d12d5 100644 --- a/sys/alpha/conf/NOTES +++ b/sys/alpha/conf/NOTES @@ -63,7 +63,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console options KTRACE #ktrace(1) syscall trace support options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues diff --git a/sys/alpha/conf/SIMOS b/sys/alpha/conf/SIMOS index cc77f250a876..3064fdd1eb3e 100644 --- a/sys/alpha/conf/SIMOS +++ b/sys/alpha/conf/SIMOS @@ -31,7 +31,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options "COMPAT_43" #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=100 #Be pessimistic about Joe SCSI device -options UCONSOLE #Allow users to grab the console config kernel diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index c59c0b6dc831..4739922e77f3 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -44,7 +44,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console #options USERCONFIG #boot -c editor #options VISUAL_USERCONFIG #visual boot -c editor options KTRACE #ktrace(1) support diff --git a/sys/conf/NOTES b/sys/conf/NOTES index d1b8e3bc7005..8eec0ca6af73 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -427,10 +427,6 @@ options PERFMON options COMPILING_LINT -# XXX - this doesn't belong here. -# Allow ordinary users to take the console - this is useful for X. -options UCONSOLE - # XXX - this doesn't belong here either #options USERCONFIG #boot -c editor #options INTRO_USERCONFIG #imply -c and show intro screen diff --git a/sys/conf/options b/sys/conf/options index 2824aa81aa1f..e84375b30fc8 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -97,7 +97,6 @@ MSGMNI opt_sysvipc.h MSGSEG opt_sysvipc.h MSGSSZ opt_sysvipc.h MSGTQL opt_sysvipc.h -UCONSOLE VFS_AIO # POSIX kernel options diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index c59c0b6dc831..4739922e77f3 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -44,7 +44,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console #options USERCONFIG #boot -c editor #options VISUAL_USERCONFIG #visual boot -c editor options KTRACE #ktrace(1) support diff --git a/sys/i386/conf/NEWCARD b/sys/i386/conf/NEWCARD index c1fab09a0079..99b237ba88cb 100644 --- a/sys/i386/conf/NEWCARD +++ b/sys/i386/conf/NEWCARD @@ -48,7 +48,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console #options USERCONFIG #boot -c editor #options VISUAL_USERCONFIG #visual boot -c editor options KTRACE #ktrace(1) support diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index d1b8e3bc7005..8eec0ca6af73 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -427,10 +427,6 @@ options PERFMON options COMPILING_LINT -# XXX - this doesn't belong here. -# Allow ordinary users to take the console - this is useful for X. -options UCONSOLE - # XXX - this doesn't belong here either #options USERCONFIG #boot -c editor #options INTRO_USERCONFIG #imply -c and show intro screen diff --git a/sys/ia64/conf/GENERIC b/sys/ia64/conf/GENERIC index 0ca6d2cd13cb..fbcc1ccfacff 100644 --- a/sys/ia64/conf/GENERIC +++ b/sys/ia64/conf/GENERIC @@ -48,7 +48,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console options KTRACE #ktrace(1) syscall trace support options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues diff --git a/sys/ia64/conf/SKI b/sys/ia64/conf/SKI index 20ace1ed0405..a54d35d6f2d6 100644 --- a/sys/ia64/conf/SKI +++ b/sys/ia64/conf/SKI @@ -47,7 +47,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=2000 #Delay (in ms) before probing SCSI -options UCONSOLE #Allow users to grab the console options KTRACE #ktrace(1) syscall trace support options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 3b7739dfe8bb..b698977877b9 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -68,13 +68,13 @@ */ #include "opt_compat.h" -#include "opt_uconsole.h" #include #include #include #include #include +#include #include #if defined(COMPAT_43) || defined(COMPAT_SUNOS) #include @@ -849,13 +849,23 @@ ttioctl(tp, cmd, data, flag) } case TIOCCONS: /* become virtual console */ if (*(int *)data) { + struct nameidata nid; + if (constty && constty != tp && ISSET(constty->t_state, TS_CONNECTED)) return (EBUSY); -#ifndef UCONSOLE - if ((error = suser(td)) != 0) + + /* Ensure user can open the real console. */ + NDINIT(&nid, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, + "/dev/console", td); + if ((error = namei(&nid)) != 0) return (error); -#endif + NDFREE(&nid, NDF_ONLY_PNBUF); + error = VOP_ACCESS(nid.ni_vp, VREAD, td->td_ucred, td); + vput(nid.ni_vp); + if (error) + return (error); + constty = tp; } else if (tp == constty) constty = NULL; diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC index 1e4e6347e3e6..120174bd22af 100644 --- a/sys/pc98/conf/GENERIC +++ b/sys/pc98/conf/GENERIC @@ -49,7 +49,6 @@ options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI options EPSON_BOUNCEDMA #use bounce buufer for 15-16M #options EPSON_MEMWIN #EPSON memory window support -options UCONSOLE #Allow users to grab the console #options LINE30 #options USERCONFIG #boot -c editor #options VISUAL_USERCONFIG #visual boot -c editor diff --git a/sys/sparc64/conf/GENERIC b/sys/sparc64/conf/GENERIC index d7081afafcfc..7409a2a6ae4f 100644 --- a/sys/sparc64/conf/GENERIC +++ b/sys/sparc64/conf/GENERIC @@ -49,7 +49,6 @@ options PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS #Pseudo-filesystem framework options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] #options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI -#options UCONSOLE #Allow users to grab the console options KTRACE #ktrace(1) syscall trace support options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues