lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHtARFFtV051-VPhvw1osMXf6fpn3Obgta3gWd5Y+2EcQx_u3A@mail.gmail.com>
Date:   Fri, 10 Nov 2017 11:43:41 -0800
From:   adam radford <aradford@...il.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Sumit Saxena <sumit.saxena@...adcom.com>,
        linux-scsi <linux-scsi@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] scsi: 3ware: use 64-bit times for FW time sync

On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann <arnd@...db.de> wrote:
> The calculation of the number of seconds since Sunday 00:00:00 overflows
> in 2106, meaning that we instead will return the seconds since Wednesday
> 06:28:16 afterwards.
>
> Using 64-bit time stamps avoids this slight inconsistency, and the
> deprecated do_gettimeofday(), replacing it with the simpler
> ktime_get_real_seconds().
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/scsi/3w-9xxx.c |  8 +++-----
>  drivers/scsi/3w-sas.c  | 10 ++++------
>  2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index cb9af3f7b653..b1c9bd9c1bfd 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -472,11 +472,10 @@ static char *twa_aen_severity_lookup(unsigned char severity_code)
>  static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
>         u32 schedulertime;
> -       struct timeval utc;
>         TW_Command_Full *full_command_packet;
>         TW_Command *command_packet;
>         TW_Param_Apache *param;
> -       u32 local_time;
> +       time64_t local_time;
>
>         /* Fill out the command packet */
>         full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -498,9 +497,8 @@ static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>
>         /* Convert system time in UTC to local time seconds since last
>             Sunday 12:00AM */
> -       do_gettimeofday(&utc);
> -       local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> -       schedulertime = local_time - (3 * 86400);
> +       local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60));
> +       div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime);
>         schedulertime = cpu_to_le32(schedulertime % 604800);
>
>         memcpy(param->data, &schedulertime, sizeof(u32));
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index c283fdb3cb24..cf9f2a09b47d 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -407,11 +407,10 @@ static int twl_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
>  static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
>         u32 schedulertime;
> -       struct timeval utc;
>         TW_Command_Full *full_command_packet;
>         TW_Command *command_packet;
>         TW_Param_Apache *param;
> -       u32 local_time;
> +       time64_t local_time;
>
>         /* Fill out the command packet */
>         full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -433,10 +432,9 @@ static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>
>         /* Convert system time in UTC to local time seconds since last
>             Sunday 12:00AM */
> -       do_gettimeofday(&utc);
> -       local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> -       schedulertime = local_time - (3 * 86400);
> -       schedulertime = cpu_to_le32(schedulertime % 604800);
> +       local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60));
> +       div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime);
> +       schedulertime = cpu_to_le32(schedulertime);
>
>         memcpy(param->data, &schedulertime, sizeof(u32));
>
> --
> 2.9.0
>

Acked-by: Adam Radford <aradford@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ