Message ID | 20171110155840.1941250-1-arnd@arndb.de |
---|---|
State | New |
Headers | show |
Series | [1/3] scsi: 3ware: fix 32-bit time calculations | expand |
On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann <arnd@arndb.de> 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 <arnd@arndb.de> > --- > 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 <aradford@gmail.com>
Arnd, > 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. Applied to 4.16/scsi-queue. -- Martin K. Petersen Oracle Linux Engineering
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;
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 <arnd@arndb.de> --- drivers/scsi/3w-9xxx.c | 5 ++--- drivers/scsi/3w-sas.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) -- 2.9.0