Messages in this thread | | | Date | Thu, 25 Apr 2013 08:43:09 -0700 | Subject | Re: [PATCH] TTY: fix atime/mtime regression | From | Linus Torvalds <> |
| |
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
| |