[3.5.y.z,extended,stable] Patch "TTY: fix atime/mtime regression" has been added to staging queue

Message ID 1367451223-19403-1-git-send-email-luis.henriques@canonical.com
State New
Headers show

Commit Message

Luis Henriques May 1, 2013, 11:33 p.m.
This is a note to let you know that I have just added a patch titled

    TTY: fix atime/mtime regression

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:


If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see



From ab35f2b785046329b311bb4e5c1dc391b39e25b6 Mon Sep 17 00:00:00 2001
From: Jiri Slaby <jslaby@suse.cz>
Date: Fri, 26 Apr 2013 13:48:53 +0200
Subject: [PATCH] TTY: fix atime/mtime regression

commit 37b7f3c76595e23257f61bd80b223de8658617ee upstream.

In commit b0de59b5733d ("TTY: do not update atime/mtime on read/write")
we removed timestamps from tty inodes to fix a security issue and waited
if something breaks.  Well, 'w', the utility to find out logged users
and their inactivity time broke.  It shows that users are inactive since
the time they logged in.

To revert to the old behaviour while still preventing attackers to
guess the password length, we update the timestamps in one-minute
intervals by this patch.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ luis: backport to 3.5: don't use file_inode() ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
 drivers/tty/tty_io.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)



diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e0767b7..95a37fa 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -939,6 +939,14 @@  void start_tty(struct tty_struct *tty)


+static void tty_update_time(struct timespec *time)
+	unsigned long sec = get_seconds();
+	sec -= sec % 60;
+	if ((long)(sec - time->tv_sec) > 0)
+		time->tv_sec = sec;
  *	tty_read	-	read method for tty device files
  *	@file: pointer to tty file
@@ -976,6 +984,9 @@  static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
 		i = -EIO;

+	if (i > 0)
+		tty_update_time(&inode->i_atime);
 	return i;

@@ -1076,8 +1087,11 @@  static inline ssize_t do_tty_write(
-	if (written)
+	if (written) {
+		struct inode *inode = file->f_path.dentry->d_inode;
+		tty_update_time(&inode->i_mtime);
 		ret = written;
+	}
 	return ret;