Received: by 10.223.164.202 with SMTP id h10csp615114wrb; Fri, 10 Nov 2017 11:42:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMa4bU4Vjs9hxH+/KO7tcz50XY/W5xGapsxdpvA81NlLZpHQLcB3UBvUvxTJeWJcilAfdpB0 X-Received: by 10.99.121.140 with SMTP id u134mr1357132pgc.16.1510342977924; Fri, 10 Nov 2017 11:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510342977; cv=none; d=google.com; s=arc-20160816; b=sFzjbkshpdt4Awi0deHAgChQBrXc7mBVpWdU+voNZyiZuXKC8BSVCANpl50ojyzqS5 vc1TP5/UYbKPv+eAghBM5OAsI7/Gxrwg+B0UTbcNdBHhNmkdqPkVIQXJXXpxgfhY+T8f H/95q3TVeE1OeqFFC0P4I587NbmJ01vjKuOiAyptp/F/l63TfiZvdZtXvx7P3gaRicFN iHTs5j5cFS8tXuTVnRydAYfCKHmOmq13Epu8sgfqdaphgRO6j1W1tbaFjMI5aBuv7EJ1 Ui/+w2i8bTUQjUhx86KYQYBQW6f9Dy8JnTavYuGRW1gwmMelYIBXyxC3S0DJTc8SHYA6 LREw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=DgwELsKLAA2gzLZX9xLNFoyQx292qi0+hjwTxDE35yk=; b=awL2SuWNAU16XX7Ce5Up5s1afId8EbHmngqhTw9qLKhzp3uvOzNeqxJ406uuKvWv8S fb05ZG4uZFCoMr+fprq6zGyGYo1DmSRkleOBY7cxpiBixe9he52fB/CAfIfsU+nZqLGU +8cWaCwEAEul8Mnt4/JY3CjevN5NQwyYWHlyXxwDZ0xmeDMIccr6J1iDzaRIws0FiVvK UHUh4XLYb5+l168v+REGS7UE7g5GMEgy868eBDGHOtFLD/ao+m9dAAfTX+AJFq+or0G9 aGF8m5eUqZpcNwjAva31QwHyhFo5FnoRlQz9ISZ/JBfU8RevmC98aFyP68PfrWzzW0T6 n49w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s3jaCUFh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si9360819pgq.501.2017.11.10.11.42.46; Fri, 10 Nov 2017 11:42:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s3jaCUFh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753960AbdKJTmJ (ORCPT + 82 others); Fri, 10 Nov 2017 14:42:09 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:56683 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753632AbdKJTmI (ORCPT ); Fri, 10 Nov 2017 14:42:08 -0500 Received: by mail-ot0-f195.google.com with SMTP id j29so5634583oth.13; Fri, 10 Nov 2017 11:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DgwELsKLAA2gzLZX9xLNFoyQx292qi0+hjwTxDE35yk=; b=s3jaCUFhV7YIJdUiDGdJDzbvn61uHW2X1YBMfn43z3PtcOCSGKHPzBQ+Sy3jdURTly Fi2m9LMtq7VRLpFVbqsLcDEd9xPh6whTOLqCPoSKHDW4ObWpm7wjtuzQ/y9K8rE28IeV 2/ItzQ1v9KklkkuhNXGYrIAicl6p9OaQTrg9VY0o/8cTA2fAzdCpkWtpzimi44SEYtkc FlHIkP6BhYSZr/ZSDOm+k1DcR5EsjQi/KdK/A+Z8APynSr61gXbfl436zuyqunw3nId7 yx0q+64ZDWpWsEbmagtN9GR6rmSLAoHFEa5n+7s5YpuQ5bWWPAeYlbTQBpolk9Sr2K/A AEpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DgwELsKLAA2gzLZX9xLNFoyQx292qi0+hjwTxDE35yk=; b=DlKmMDrfJXNvjdkuMz3c2ksVtCOcZxyp59r6lVryBkKWC7w3BKx5BOurG2ClFypjFE ria9aCd5+H1biSdeFg/JoUlSjKbb2gPlKXUSHiBi89mBDUcak0AzUjSH4TPMkpq8NO0Y X0IPw4QXYEWdNtJS4dPv4OaXfQ3QRfc6pqy9b8xk8gbuh/AYwnKINxhx5SjUQqCgVCca /uJPAfQifpl+XS8YMmj5g2AJv1Qk6NntuZXqkzQjJYfHVdtwAUSARP3j7d9OCdIGZqVo qndgSiFqTQzTH4VoEHwSYBB7qEQO8y+rGy7W4tDo8wzxjd8BdBNgIylORhiN286NP+Wm S5vA== X-Gm-Message-State: AJaThX5tIPonZL+5jdC+mwopHZZMls1OrbaFSs+tNjnIbj31tfb0yDPL x8aWhHjgMJhFfHvTNGP2O4sbTaz9AuX9Tv/szAQ= X-Received: by 10.157.66.182 with SMTP id r51mr901490ote.306.1510342927279; Fri, 10 Nov 2017 11:42:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.110.153 with HTTP; Fri, 10 Nov 2017 11:42:06 -0800 (PST) In-Reply-To: <20171110155840.1941250-1-arnd@arndb.de> References: <20171110155840.1941250-1-arnd@arndb.de> From: adam radford Date: Fri, 10 Nov 2017 11:42:06 -0800 Message-ID: Subject: Re: [PATCH 1/3] scsi: 3ware: fix 32-bit time calculations To: Arnd Bergmann Cc: "James E.J. Bottomley" , "Martin K. Petersen" , Sumit Saxena , linux-scsi , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann wrote: > 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(-) > > 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; > -- > 2.9.0 > Acked-by: Adam Radford From 1583695402644133525@xxx Fri Nov 10 16:00:30 +0000 2017 X-GM-THRID: 1583695402644133525 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread