]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.72/tty-fix-up-atime-mtime-mess-take-four.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.72 / tty-fix-up-atime-mtime-mess-take-four.patch
CommitLineData
cca31f78
GKH
1From f0bf0bd07943bfde8f5ac39a32664810a379c7d3 Mon Sep 17 00:00:00 2001
2From: Jiri Slaby <jslaby@suse.cz>
3Date: Fri, 27 Feb 2015 18:40:31 +0100
4Subject: tty: fix up atime/mtime mess, take four
5
6From: Jiri Slaby <jslaby@suse.cz>
7
8commit f0bf0bd07943bfde8f5ac39a32664810a379c7d3 upstream.
9
10This problem was taken care of three times already in
11* b0de59b5733d18b0d1974a060860a8b5c1b36a2e (TTY: do not update
12 atime/mtime on read/write),
13* 37b7f3c76595e23257f61bd80b223de8658617ee (TTY: fix atime/mtime
14 regression), and
15* b0b885657b6c8ef63a46bc9299b2a7715d19acde (tty: fix up atime/mtime
16 mess, take three)
17
18But it still misses one point. As John Paul correctly points out, we
19do not care about setting date. If somebody ever changes wall
20time backwards (by mistake for example), tty timestamps are never
21updated until the original wall time passes.
22
23So check the absolute difference of times and if it large than "8
24seconds or so", always update the time. That means we will update
25immediatelly when changing time. Ergo, CAP_SYS_TIME can foul the
26check, but it was always that way.
27
28Thanks John for serving me this so nicely debugged.
29
30Signed-off-by: Jiri Slaby <jslaby@suse.cz>
31Reported-by: John Paul Perry <john_paul.perry@alcatel-lucent.com>
32Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
33Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35
36---
37 drivers/tty/tty_io.c | 4 ++--
38 1 file changed, 2 insertions(+), 2 deletions(-)
39
40--- a/drivers/tty/tty_io.c
41+++ b/drivers/tty/tty_io.c
42@@ -992,8 +992,8 @@ EXPORT_SYMBOL(start_tty);
43 /* We limit tty time update visibility to every 8 seconds or so. */
44 static void tty_update_time(struct timespec *time)
45 {
46- unsigned long sec = get_seconds() & ~7;
47- if ((long)(sec - time->tv_sec) > 0)
48+ unsigned long sec = get_seconds();
49+ if (abs(sec - time->tv_sec) & ~7)
50 time->tv_sec = sec;
51 }
52