lkml.org 
[lkml]   [2013]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] TTY: fix atime/mtime regression
From
On Thu, Apr 25, 2013 at 5:40 AM, Jiri Slaby <jslaby@suse.cz> wrote:
>
> To revert to the old behaviour while still preventing attackers to
> guess the password length, we update the timestamps in ten-second
> intervals by this patch.

Hmm. Why ten seconds? Wouldn't it make more sense to use some natural
boundary, like a full minute?

Also, if I read the code correctly, this can actually make time go
*backwards* for the inode when the tty is first created. So it would
seem to be much better for tty_get_inode_time() to be passed in the
pointer to the tty time to be updated, so that it can avoid doing a
backwards jump.

Finally, if you're just interested in the seconds (like you are),
don't use "current_kernel_time()" that unnecessarily does the whole
nsec calculation. Just do "get_seconds()".

IOW, the end result would be something like

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;
}

(That whole "(long)(sec - time->tv_sec)" is to handle wrapping time
correctly, we don't want to stop updating the inode in 2038 on 32-bit
machines).

Hmm?

Linus


\
 
 \ /
  Last update: 2013-04-25 18:01    [W:2.036 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site