Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: bfa: document overflow of io_profile_start_time

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>

authored by

Arnd Bergmann and committed by
Martin K. Petersen
aa22a52e 03d32af3

+5 -6
+2 -1
drivers/scsi/bfa/bfa_fcpim.c
··· 468 468 } 469 469 470 470 bfa_status_t 471 - bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time) 471 + bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time) 472 472 { 473 473 struct bfa_itnim_s *itnim; 474 474 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa); ··· 1478 1478 return BFA_STATUS_IOPROFILE_OFF; 1479 1479 1480 1480 itnim->ioprofile.index = BFA_IOBUCKET_MAX; 1481 + /* unsigned 32-bit time_t overflow here in y2106 */ 1481 1482 itnim->ioprofile.io_profile_start_time = 1482 1483 bfa_io_profile_start_time(itnim->bfa); 1483 1484 itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
+2 -2
drivers/scsi/bfa/bfa_fcpim.h
··· 136 136 struct bfa_fcpim_del_itn_stats_s del_itn_stats; 137 137 bfa_boolean_t ioredirect; 138 138 bfa_boolean_t io_profile; 139 - u32 io_profile_start_time; 139 + time64_t io_profile_start_time; 140 140 bfa_fcpim_profile_t profile_comp; 141 141 bfa_fcpim_profile_t profile_start; 142 142 }; ··· 310 310 struct bfa_itnim_iostats_s *stats, u8 lp_tag); 311 311 void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats, 312 312 struct bfa_itnim_iostats_s *itnim_stats); 313 - bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time); 313 + bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time); 314 314 bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa); 315 315 316 316 #define bfa_fcpim_ioredirect_enabled(__bfa) \
+1 -3
drivers/scsi/bfa/bfad_bsg.c
··· 2094 2094 { 2095 2095 struct bfa_bsg_fcpim_profile_s *iocmd = 2096 2096 (struct bfa_bsg_fcpim_profile_s *)cmd; 2097 - struct timeval tv; 2098 2097 unsigned long flags; 2099 2098 2100 - do_gettimeofday(&tv); 2101 2099 spin_lock_irqsave(&bfad->bfad_lock, flags); 2102 2100 if (v_cmd == IOCMD_FCPIM_PROFILE_ON) 2103 - iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec); 2101 + iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, ktime_get_real_seconds()); 2104 2102 else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF) 2105 2103 iocmd->status = bfa_fcpim_profile_off(&bfad->bfa); 2106 2104 spin_unlock_irqrestore(&bfad->bfad_lock, flags);