diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-06-17 17:58:26 +0300 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-06-18 00:39:58 +0300 |
commit | 59a37f8baeb2c9d97f316584c90892d18bf846d4 (patch) | |
tree | bfca0df952a0c306141d341f1d1a6bfc8923baee /kernel/trace/blktrace.c | |
parent | e1f3b9412edb22774cebf47e353b6ccc1b779cfe (diff) | |
download | linux-59a37f8baeb2c9d97f316584c90892d18bf846d4.tar.xz |
blktrace: avoid using timespec
The blktrace code stores the current time in a 32-bit word in its
user interface. This is a bad idea because 32-bit seconds overflow
at some point.
We probably have until 2106 before this one overflows, as it seems
to use an 'unsigned' variable, but we should confirm that user
space treats it the same way.
Aside from this, we want to stop using 'struct timespec' here,
so I'm adding a comment about the overflow and change the code
to use timespec64 instead to make the loss of range more obvious.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | kernel/trace/blktrace.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 03b0dd98ff0e..bedb84d168d1 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -127,12 +127,13 @@ static void trace_note_tsk(struct task_struct *tsk) static void trace_note_time(struct blk_trace *bt) { - struct timespec now; + struct timespec64 now; unsigned long flags; u32 words[2]; - getnstimeofday(&now); - words[0] = now.tv_sec; + /* need to check user space to see if this breaks in y2038 or y2106 */ + ktime_get_real_ts64(&now); + words[0] = (u32)now.tv_sec; words[1] = now.tv_nsec; local_irq_save(flags); |