]> git.hungrycats.org Git - linux/commitdiff
[PATCH] TIOCCONS security
authorOlaf Dabrunz <od@suse.de>
Tue, 19 Oct 2004 00:59:16 +0000 (17:59 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 19 Oct 2004 00:59:16 +0000 (17:59 -0700)
The ioctl TIOCCONS allows any user to redirect console output to another
tty.  This allows anyone to suppress messages to the console at will.

AFAIK nowadays not many programs write to /dev/console, except for start
scripts and the kernel (printk() above console log level).

Still, I believe that administrators and operators would not like any user
to be able to hijack messages that were written to the console.

The only user of TIOCCONS that I am aware of is bootlogd/blogd, which runs
as root.  Please comment if there are other users.

Is there any reason why normal users should be able to use TIOCCONS?

Otherwise I would suggest to restrict access to root (CAP_SYS_ADMIN), e.g.
with this patch.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/tty_io.c

index 89457cc2ed72522e2aea54babdbdb055c7545ad5..9d5e4ba9dc2559b38fc223b80db778ac28e7f88a 100644 (file)
@@ -1981,10 +1981,10 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty,
 
 static int tioccons(struct file *file)
 {
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
        if (file->f_op->write == redirected_tty_write) {
                struct file *f;
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
                spin_lock(&redirect_lock);
                f = redirect;
                redirect = NULL;