scsi: bfa: document overflow of io_profile_start_time
authorArnd Bergmann <arnd@arndb.de>
Fri, 10 Nov 2017 15:37:12 +0000 (16:37 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 5 Dec 2017 01:32:52 +0000 (20:32 -0500)
io_profile_start_time() gets read using do_gettimeofday() and passed
down as a 32-bit value through multiple functions. This will overflow in
y2038 or y2106, depending on whether it gets interpreted as unsigned in
the end.

This changes do_gettimeofday() to ktime_get_real_seconds() and pushes
the point at which it overflows to where we actually assign it to the
bfa_fcpim_del_itn_stats_s structure, with an appropriate comment.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Anil Gurumurthy <Anil.Gurumurthy@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/bfa/bfa_fcpim.c
drivers/scsi/bfa/bfa_fcpim.h
drivers/scsi/bfa/bfad_bsg.c

index 5f53b3276234bbb372bde642199d1ebbbcad228e..2c85f5b1f9c1c0f082764bee358aaa302887d4fa 100644 (file)
@@ -468,7 +468,7 @@ bfa_ioim_profile_start(struct bfa_ioim_s *ioim)
 }
 
 bfa_status_t
-bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time)
+bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time)
 {
        struct bfa_itnim_s *itnim;
        struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
@@ -1478,6 +1478,7 @@ bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
                return BFA_STATUS_IOPROFILE_OFF;
 
        itnim->ioprofile.index = BFA_IOBUCKET_MAX;
+       /* unsigned 32-bit time_t overflow here in y2106 */
        itnim->ioprofile.io_profile_start_time =
                                bfa_io_profile_start_time(itnim->bfa);
        itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
index e93921dec3478a3b5d68e30943b34cc55f41d3cc..ec8f863540aee737722a969f2eda5f16527df5ee 100644 (file)
@@ -136,7 +136,7 @@ struct bfa_fcpim_s {
        struct bfa_fcpim_del_itn_stats_s del_itn_stats;
        bfa_boolean_t           ioredirect;
        bfa_boolean_t           io_profile;
-       u32                     io_profile_start_time;
+       time64_t                io_profile_start_time;
        bfa_fcpim_profile_t     profile_comp;
        bfa_fcpim_profile_t     profile_start;
 };
@@ -310,7 +310,7 @@ bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa,
                        struct bfa_itnim_iostats_s *stats, u8 lp_tag);
 void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats,
                        struct bfa_itnim_iostats_s *itnim_stats);
-bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time);
+bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time);
 bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa);
 
 #define bfa_fcpim_ioredirect_enabled(__bfa)                            \
index 72ca2a2e08e259b70be45e8880354bf8291ef9c4..01fc51a70356bfb2814a94b90e7ec0b5bee779fc 100644 (file)
@@ -2094,13 +2094,11 @@ bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd)
 {
        struct bfa_bsg_fcpim_profile_s *iocmd =
                                (struct bfa_bsg_fcpim_profile_s *)cmd;
-       struct timeval  tv;
        unsigned long   flags;
 
-       do_gettimeofday(&tv);
        spin_lock_irqsave(&bfad->bfad_lock, flags);
        if (v_cmd == IOCMD_FCPIM_PROFILE_ON)
-               iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec);
+               iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, ktime_get_real_seconds());
        else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF)
                iocmd->status = bfa_fcpim_profile_off(&bfad->bfa);
        spin_unlock_irqrestore(&bfad->bfad_lock, flags);