From patchwork Fri Nov 10 15:58:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118588 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8099687qgn; Fri, 10 Nov 2017 07:59:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMad50vbtIUg7KkpxZZRRf90qP1uhtQY96phQWooBCVaiasCkxaeCr6UBfW+480PLV0Hegko X-Received: by 10.99.3.146 with SMTP id 140mr749475pgd.275.1510329569540; Fri, 10 Nov 2017 07:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510329569; cv=none; d=google.com; s=arc-20160816; b=ccg+HVJjOHSoF3Ul8Z08ke5H7HCv8ueuYoPoPDPvrawEtaIbjD8EIn2GXOPGDp0XW0 rYs18g4KjkNcOti7wEAfR6skQaNfsaRqjLHi9djkz77Nsf4gFGOJz4lfkNxz6S5pniam nMSLRvLzVI4wnR8u4M00WrDwZfR7yNZ63MDd1AoRj8nVT9jT8q0IWAnmaXLfPadTWeMj 5AENzhkg1LS2H2UW6Sfc1qV3U2HbtQYLKkkFyju63/Xk4Wx6ZM2DSvBsfmiBnuoycD0u cnd9SLB63beZauZdWXiIW34fNSObr48bWnzawY5Y/QtlAFXt/gn6v+ZcJNWaHR39Si6z ibNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zKgRwD7vvPjR1A1ZBtb4MowCCxAHu4VqFRCMdc5j3/A=; b=kYiQJjz/HjrpJfgbUFTUxJgF6ACVyC7XMMtXl4C2GeeFhlb2pR7b1WQjyogJEFxrBx LPjvDAdWnpzxVZGwxCfu4gpCmI7SbMGMAgNe7EPKYgoGNNM76pn6eyO67vk37cTGxfDf pVqzw/cE3NwbRpmw2rKLviuzyZ/gahjBfARa+QCs/c+RNG6eiWs5tT88pYfdNivnR7iH enu6NmDmLlAiWtR1PVdhg/vZHU2dqwcZUnIEoBz7eJcQ5UkFEv5rzG9JpyyMtBWeqikm HmqK7Jo/lxVK9NGPe4pGTstthI5sLbUsn239ghsTlL2+y7LqxZE8jXdmo/yjXnqVWcSF 4LRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si9109878pld.115.2017.11.10.07.59.29; Fri, 10 Nov 2017 07:59:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbdKJP72 (ORCPT + 24 others); Fri, 10 Nov 2017 10:59:28 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:64187 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbdKJP70 (ORCPT ); Fri, 10 Nov 2017 10:59:26 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Luaps-1fCbyb3k12-00zp4q; Fri, 10 Nov 2017 16:58:42 +0100 From: Arnd Bergmann To: Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Sumit Saxena , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] scsi: 3ware: fix 32-bit time calculations Date: Fri, 10 Nov 2017 16:58:25 +0100 Message-Id: <20171110155840.1941250-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:5NNgyRlEH1VpKYg/dNzJfWlbFa35WvhH1ZyHkDNfoUkTghU5YPR 5nUxJB7ZRn0wxReVXQ7OiTA+BLiVvS7zW4cbX0BWxfUUF+qEshV+wXAiGiVBCQuuF64qHnO 6Ws9RIW+zLgpY2UZRdjyfjRa60n198sZB557OHxqDnF5ce3pw+JbtyqmSzmSK3rDJNPmA0f u/Pe3xDlzBM3raxnQSMKA== X-UI-Out-Filterresults: notjunk:1; V01:K0:IoWl24KxsYU=:x5xuZ8f211toj2vqXQf0/P wWuMRrnRLrJc2pUuRrHyqV0p6tVj90YggAfdxzkvgIVhF0bHQtL84bdRIzMB83h8jtUkEm+Ef CvArTPUAnalLU2RuNqyuRquh2dqePFfExnxIDDzN2KTwAIQbfYvuqsQjofoUNxyrw1NyCZ/OB 8FUjEfwpEfvs5ch779F5HpAsbp2j7Qz4FF8fxnSR5rEh1TkLTmq7zABuBSrc85ohQfDFpJaWd FTsWPDigrzTzqiPKhEKTlZRWsExWnbTQqfK6KlNaUNx4/bYDnlyrrYjbd/60EQFIcil/ze5W/ ZkTEbTjOxu6v1f0dB6/372PBIHcGoUizeS/FsfsHn2Qn5R5umoSzczsWsa4Om0wYtReyYXDNW 1HpDwRaHdvTR66fM9mG8SGj8/5lWMhJkcLa82ShA4UcctyJHf1sFvNfUG73eT3NfXRFahJJsk BgucPBnxunlgBuz8NzYFpzLpV0A+WWVQzRC/phIR56dab8fUqXQJLrA41YpTQrx6q+6efvIEX YcokiutspcbhnL0E74KlKP0vKlV/z5jZmEIQX41Ckt2uT8Rry/+YYUJQFtmMzOLQmp5G031iG ooJmtywdo2FRZxqCf3DGv9S0XIDo62vuGgRrdJldEk0vYXCM2l/BkUTWwCwjyqp6B+XU1DW2P uD8i1kPMERHToVSW9fJTMhCiK+S0B75fG5N97bhNL1f41fhHpGO7WNqRytByarbwxn/gxCnTi ll5/O8UknAGWM2dxtilbgwFm8xslxwAJNgS0mA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org twl_aen_queue_event/twa_aen_queue_event, we use do_gettimeofday() to read the lower 32 bits of the current time in seconds, to pass them to the TW_IOCTL_GET_NEXT_EVENT ioctl or the 3ware_aen_read sysfs file. This will overflow on all architectures in year 2106, there is not much we can do about that without breaking the ABI. User space has 90 years to learn to deal with it, so it's probably ok. I'm changing it to use ktime_get_real_seconds() with a comment to document what happens when. Signed-off-by: Arnd Bergmann --- drivers/scsi/3w-9xxx.c | 5 ++--- drivers/scsi/3w-sas.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) -- 2.9.0 Acked-by: Adam Radford diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 00e7968a1d70..cb9af3f7b653 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -369,7 +369,6 @@ static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset) static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header) { u32 local_time; - struct timeval time; TW_Event *event; unsigned short aen; char host[16]; @@ -392,8 +391,8 @@ static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_H memset(event, 0, sizeof(TW_Event)); event->severity = TW_SEV_OUT(header->status_block.severity__reserved); - do_gettimeofday(&time); - local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + /* event->time_stamp_sec overflows in y2106 */ + local_time = (u32)(ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60)); event->time_stamp_sec = local_time; event->aen_code = aen; event->retrieved = TW_AEN_NOT_RETRIEVED; diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index b150e131b2e7..c283fdb3cb24 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -221,7 +221,6 @@ static char *twl_aen_severity_lookup(unsigned char severity_code) static void twl_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header) { u32 local_time; - struct timeval time; TW_Event *event; unsigned short aen; char host[16]; @@ -240,8 +239,8 @@ static void twl_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_H memset(event, 0, sizeof(TW_Event)); event->severity = TW_SEV_OUT(header->status_block.severity__reserved); - do_gettimeofday(&time); - local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + /* event->time_stamp_sec overflows in y2106 */ + local_time = (u32)(ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60)); event->time_stamp_sec = local_time; event->aen_code = aen; event->retrieved = TW_AEN_NOT_RETRIEVED;