diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-26 18:10:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-26 18:10:27 -0400 |
commit | fbf47635315ab308c9b58a1ea0906e711a9228de (patch) | |
tree | eaf51ea4136a36e007109db421737cc68ca2f33a /drivers/tty | |
parent | 23f5b3fdd04e89b4c67fd9ffa60a193d239acf0f (diff) |
tty: clean up the tty time logic a bit
We only care if anything other than the lower 3 bits of the tty has
changed, so just check that way, which makes it a bit faster, and more
obvious what is going on. Also, document this for future developers to
understand why we did this.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_io.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 3949d9527e6d..e5695467598f 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -1025,11 +1025,17 @@ void start_tty(struct tty_struct *tty) | |||
1025 | } | 1025 | } |
1026 | EXPORT_SYMBOL(start_tty); | 1026 | EXPORT_SYMBOL(start_tty); |
1027 | 1027 | ||
1028 | /* We limit tty time update visibility to every 8 seconds or so. */ | ||
1029 | static void tty_update_time(struct timespec *time) | 1028 | static void tty_update_time(struct timespec *time) |
1030 | { | 1029 | { |
1031 | unsigned long sec = get_seconds(); | 1030 | unsigned long sec = get_seconds(); |
1032 | if (abs(sec - time->tv_sec) & ~7) | 1031 | |
1032 | /* | ||
1033 | * We only care if the two values differ in anything other than the | ||
1034 | * lower three bits (i.e every 8 seconds). If so, then we can update | ||
1035 | * the time of the tty device, otherwise it could be construded as a | ||
1036 | * security leak to let userspace know the exact timing of the tty. | ||
1037 | */ | ||
1038 | if ((sec ^ time->tv_sec) & ~7) | ||
1033 | time->tv_sec = sec; | 1039 | time->tv_sec = sec; |
1034 | } | 1040 | } |
1035 | 1041 | ||