[PATCH] TTY: do not update atime/mtime on read/write

From: Jiri Slaby
Date: Fri Feb 15 2013 - 09:25:22 EST

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.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
References: CVE-2013-0160
drivers/tty/tty_io.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index a86219c..8801385 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -980,8 +980,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
i = -EIO;
- if (i > 0)
- inode->i_atime = current_fs_time(inode->i_sb);
return i;

@@ -1082,11 +1081,8 @@ static inline ssize_t do_tty_write(
- if (written) {
- struct inode *inode = file->f_path.dentry->d_inode;
- inode->i_mtime = current_fs_time(inode->i_sb);
+ if (written)
ret = written;
- }
return ret;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/