From patchwork Fri Jun 17 14:58:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9184245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1DF30601C0 for ; Fri, 17 Jun 2016 14:57:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C3B127248 for ; Fri, 17 Jun 2016 14:57:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10E132839C; Fri, 17 Jun 2016 14:57:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5311227248 for ; Fri, 17 Jun 2016 14:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbcFQO5d (ORCPT ); Fri, 17 Jun 2016 10:57:33 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:51955 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751757AbcFQO5d (ORCPT ); Fri, 17 Jun 2016 10:57:33 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0LgYcf-1bi4u40hXB-00nw6N; Fri, 17 Jun 2016 16:57:05 +0200 From: Arnd Bergmann To: Jens Axboe , Steven Rostedt , Ingo Molnar Cc: y2038@lists.linaro.org, Arnd Bergmann , Hannes Reinecke , Mike Christie , Shaohua Li , 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 Message-Id: <20160617145849.3771756-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:CktAmYRzhb1KrgNr1Fco14Tm2waXHCktT1rqMM6C0lYkuf6ZLnL QbSQgj2uF1qKOyubTqfkuXak7DCluAiNcc0gdyuXWLfhLxly9vmQcWmH1sSSGmuc3apitcK 6rnq+4XC6EWH1a1Jz3K33nEBmtrvcq1SWi0FKE9Auvs9PPGUtqEPhglhitND0zRaH2lzrRJ IGG5/Bx2kITJNqhR9PLGw== X-UI-Out-Filterresults: notjunk:1; V01:K0:lASAYeMyOyg=:LznLf4Ss6pHEn+LAA7y2L+ L9PssdIHRQMItftNI6gBMHcp5rOHVGqTnceFMyXaqx/8MOtIS036lW1Xz8Hw+HO3jWQY433Gb FhVtYXT7ErM5dK4PlzNyNv8tn8xUKXbAtKGuDAYZYNdysxZipg4Iq0mddu1rbRO0ulxrbbMzf 1BRf0foSm/EKMIlMcAiNiZrfPnTouqHp61l3UM5OM24AX62YnRy1F1FuNDVxcmmv2NMenlJK/ js/F9LXMFO/4hj62ujxnCjAbdncrVvF90EG3mcSkAFPCvzEvcUrwfw/TxxV8eR8tADvL2qlKA JoMlFDk+e08VmouTrOb/sqjJonAgGcyctIP+9H0GJ7509naBLrRVsCoo/zQ8/0vhiMkXcxj2C 7+RF7r45qXKIVpqVgsWUVPrt/1zDVQhGzlp9s/hudeXQ9qpcDzodLLecmfrnFqYD79eucZxyT Wa9Wb7kxloBKfeRFVOBkwBjh35efREHVHsqkEGVMqgUAhFbS0tIbA4bTmlLIz7PiUzkN2NsnA 2UV3nWNyUJORdyNq7FLvmlJ7g1flQ63Flznegn05LpDOWPTmq/ZjaR/IetOGD2lUkVFDG8lHJ hlBrt8Wvag+gqCqnahT4ZPIPVW6bcKlcMUCCfn0Sl/xEKSvxTThUDSMnpZN5unkXvGjGzYA7N N8Xg38avaYVVEgamHXhOzNXJb1BOHc2Lk3Tzq46njtYaqbUFRtLcrIdacsNB1FFH33PA= Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);