On Thursday 19 November 2015 13:43:14 Alison Schofield wrote:
> struct timeval will overflow on 32-bit systems in y2038.
> Replace the use of struct timeval and do_gettimeofday() with 64 bit
> ktime_get_real_seconds.
>
> gdth uses the seconds portion of timeval in two places:
> 1) in an unsigned-32 timestamp field in the ioctl GDTIOCTL_EVENT
> 2) in an int defined local var to calculate elapsed time for a debug msg
>
> Use ktime_get_real_seconds() cast to u32 to extend these fields to y2106.
>
> Signed-off-by: Alison Schofield <[email protected]>
The patch looks correct in principle.
In the changelog above, I think it would be good to explain the
tradeoff between this and the alternative of introducing a
replacement ioctl, so the maintainers can decide if they want
to take this patch or if they think the more complex solution
should be used (including an updated user space side).
> @@ -540,8 +540,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host
> *host)
> if (estr->event_data.eu.driver.ionode == ha->hanum &&
> estr->event_source == ES_ASYNC) {
> gdth_log_event(&estr->event_data, hrec);
> - do_gettimeofday(&tv);
> - sec = (int)(tv.tv_sec - estr->first_stamp);
> + sec = (int)((u32)ktime_get_real_seconds() - estr->first_stamp);
> if (sec < 0) sec = 0;
> seq_printf(m," date- %02d:%02d:%02d\t%s\n",
> sec/3600, sec%3600/60, sec%60, hrec);
This code correctly computes the elapsed seconds, but I think you
need to add a comment to explain that it does indeed work even across
the 32-bit wraparound time.
Arnd
_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038