Re: [Y2038] [PATCH 3/7] scsi: bfa: improve bfa_ioc_send_enable/disable data

From: Arnd Bergmann
Date: Mon Nov 13 2017 - 09:55:24 EST


On Mon, Nov 13, 2017 at 3:08 PM, Ben Hutchings
<ben.hutchings@xxxxxxxxxxxxxxx> wrote:
> On Fri, 2017-11-10 at 16:37 +0100, Arnd Bergmann wrote:

>>
>> bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ,
>> bfa_ioc_portid(ioc));
>> enable_req.clscode = cpu_to_be16(ioc->clscode);
>> - do_gettimeofday(&tv);
>> - enable_req.tv_sec = be32_to_cpu(tv.tv_sec);
>> + /* unsigned 32-bit time_t overflow in y2106 */
>> + enable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds());
>
> The byte order conversion should also logically be cpu_to_be32(), not
> be32_to_cpu().
>

Right, I had not noticed that. I just tried fixing this, looking at what
sparse thinks of the file as a whole. I found it basically hopeless
to fix the endianess warnings in this driver, it seems completely
random here whether they are used correctly, in the opposite
direction as expected, or just flip data in place as in

attr->part[i].part_off = be32_to_cpu(f->part[i].part_off);

I'd rather not touch that part. IIRC I had at some point spent
a day trying to clean up the "warning: symbol
'bfa_flash_sem_get' was not declared. Should it be static?"
sparse warnings for some driver, before giving up for
similar reasons.

Arnd