Commit c29ad805 authored by Jiri Slaby's avatar Jiri Slaby Committed by Ben Hutchings

TTY: do not update atime/mtime on read/write

commit b0de59b5 upstream.

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: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 268a8c92
...@@ -976,8 +976,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, ...@@ -976,8 +976,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
else else
i = -EIO; i = -EIO;
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
if (i > 0)
inode->i_atime = current_fs_time(inode->i_sb);
return i; return i;
} }
...@@ -1078,11 +1077,8 @@ static inline ssize_t do_tty_write( ...@@ -1078,11 +1077,8 @@ static inline ssize_t do_tty_write(
break; break;
cond_resched(); cond_resched();
} }
if (written) { if (written)
struct inode *inode = file->f_path.dentry->d_inode;
inode->i_mtime = current_fs_time(inode->i_sb);
ret = written; ret = written;
}
out: out:
tty_write_unlock(tty); tty_write_unlock(tty);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment