]>
Commit | Line | Data |
---|---|---|
cca31f78 GKH |
1 | From f0bf0bd07943bfde8f5ac39a32664810a379c7d3 Mon Sep 17 00:00:00 2001 |
2 | From: Jiri Slaby <jslaby@suse.cz> | |
3 | Date: Fri, 27 Feb 2015 18:40:31 +0100 | |
4 | Subject: tty: fix up atime/mtime mess, take four | |
5 | ||
6 | From: Jiri Slaby <jslaby@suse.cz> | |
7 | ||
8 | commit f0bf0bd07943bfde8f5ac39a32664810a379c7d3 upstream. | |
9 | ||
10 | This 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 | ||
18 | But it still misses one point. As John Paul correctly points out, we | |
19 | do not care about setting date. If somebody ever changes wall | |
20 | time backwards (by mistake for example), tty timestamps are never | |
21 | updated until the original wall time passes. | |
22 | ||
23 | So check the absolute difference of times and if it large than "8 | |
24 | seconds or so", always update the time. That means we will update | |
25 | immediatelly when changing time. Ergo, CAP_SYS_TIME can foul the | |
26 | check, but it was always that way. | |
27 | ||
28 | Thanks John for serving me this so nicely debugged. | |
29 | ||
30 | Signed-off-by: Jiri Slaby <jslaby@suse.cz> | |
31 | Reported-by: John Paul Perry <john_paul.perry@alcatel-lucent.com> | |
32 | Acked-by: Linus Torvalds <torvalds@linux-foundation.org> | |
33 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
34 | Signed-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 |