From: Arnd Bergmann <arnd@arndb.de>
To: Jens Axboe <axboe@kernel.dk>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>
Cc: y2038@lists.linaro.org, Arnd Bergmann <arnd@arndb.de>,
Hannes Reinecke <hare@suse.com>,
Mike Christie <mchristi@redhat.com>, Shaohua Li <shli@fb.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] blktrace: avoid using timespec
Date: Fri, 17 Jun 2016 16:58:26 +0200 [thread overview]
Message-ID: <20160617145849.3771756-1-arnd@arndb.de> (raw)
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>
---
kernel/trace/blktrace.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index ef86b965ade3..b0816e4a61a5 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);
--
2.9.0
next reply other threads:[~2016-06-17 14:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 14:58 Arnd Bergmann [this message]
2016-06-17 15:36 ` [PATCH] blktrace: avoid using timespec Steven Rostedt
2016-06-17 21:39 ` Jens Axboe
2016-06-17 21:54 ` Jeff Moyer
2016-06-18 19:02 ` Arnd Bergmann
2016-06-20 14:59 ` Jeff Moyer
2016-06-20 15:18 ` Arnd Bergmann
2016-06-20 19:37 ` Jeff Moyer
2016-06-20 20:01 ` [Y2038] " Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160617145849.3771756-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchristi@redhat.com \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=shli@fb.com \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox