TTY: do not update atime/mtime on read/write
authorJiri Slaby <jslaby@suse.cz>
Fri, 15 Feb 2013 14:25:05 +0000 (15:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Feb 2013 18:52:36 +0000 (10:52 -0800)
On http://vladz.devzero.fr/013_ptmx-timing.php, we can see how to find
out length of a password using timestamps of /dev/ptmx. It is
documented in "Timing Analysis of Keystrokes and Timing Attacks on
SSH". To avoid that problem, do not update time when reading
from/writing to a TTY.

I am afraid of regressions as this is a behavior we have since 0.97
and apps may expect the time to be current, e.g. for monitoring
whether there was a change on the TTY. Now, there is no change. So
this would better have a lot of testing before it goes upstream.

References: CVE-2013-0160

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: stable <stable@vger.kernel.org> # after 3.9 is out
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_io.c

index 54a254ab85c73f5adc1acffde20e290194f468f5..8f44d627cceab85268ec037eec799d8c0494c7bc 100644 (file)
@@ -977,8 +977,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
        else
                i = -EIO;
        tty_ldisc_deref(ld);
-       if (i > 0)
-               inode->i_atime = current_fs_time(inode->i_sb);
+
        return i;
 }
 
@@ -1079,11 +1078,8 @@ static inline ssize_t do_tty_write(
                        break;
                cond_resched();
        }
-       if (written) {
-               struct inode *inode = file->f_path.dentry->d_inode;
-               inode->i_mtime = current_fs_time(inode->i_sb);
+       if (written)
                ret = written;
-       }
 out:
        tty_write_unlock(tty);
        return ret;