mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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
This commit is contained in:
parent
23f5b3fdd0
commit
fbf4763531
1 changed files with 8 additions and 2 deletions
|
@ -1025,11 +1025,17 @@ void start_tty(struct tty_struct *tty)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(start_tty);
|
EXPORT_SYMBOL(start_tty);
|
||||||
|
|
||||||
/* We limit tty time update visibility to every 8 seconds or so. */
|
|
||||||
static void tty_update_time(struct timespec *time)
|
static void tty_update_time(struct timespec *time)
|
||||||
{
|
{
|
||||||
unsigned long sec = get_seconds();
|
unsigned long sec = get_seconds();
|
||||||
if (abs(sec - time->tv_sec) & ~7)
|
|
||||||
|
/*
|
||||||
|
* We only care if the two values differ in anything other than the
|
||||||
|
* lower three bits (i.e every 8 seconds). If so, then we can update
|
||||||
|
* the time of the tty device, otherwise it could be construded as a
|
||||||
|
* security leak to let userspace know the exact timing of the tty.
|
||||||
|
*/
|
||||||
|
if ((sec ^ time->tv_sec) & ~7)
|
||||||
time->tv_sec = sec;
|
time->tv_sec = sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue