From patchwork Fri Nov 10 15:37:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10053373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59A8460631 for ; Fri, 10 Nov 2017 15:39:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49CBB2B372 for ; Fri, 10 Nov 2017 15:39:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E77B2B376; Fri, 10 Nov 2017 15:39:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B68622B372 for ; Fri, 10 Nov 2017 15:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753202AbdKJPjP (ORCPT ); Fri, 10 Nov 2017 10:39:15 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:57082 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbdKJPjN (ORCPT ); Fri, 10 Nov 2017 10:39:13 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lkxnh-1ekrUn2zht-00apFp; Fri, 10 Nov 2017 16:37:32 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 4/7] scsi: bfa: document overflow of io_profile_start_time Date: Fri, 10 Nov 2017 16:37:12 +0100 Message-Id: <20171110153715.1929456-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:vfy9Fw9pf0JcMyLRGU50xSUe0haSnQ1P4QDDnb2XFE0DEILHRXy PN2F+1dgzPu1PALv93JVBIMOKfWyJ/kY77Tl8r95Zd6Ea/Uaf5o1uda0g6bs5jl3r6XOP9F o1YR3m+DsdqHs9fHHLhs9BZT2Zvbw9Ng862+6v92QiHlt7UMjNcUTJhazfoow4xdwctjKut JQjQ4dbgt+BhPgluEP+RQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:5moukLrROkU=:FX1X6Jy0M0BMgSbiHetR4U 363oiR8QZCYfKpn1BGVk1keuKCsVIhu/8+B9f1bSUFvKIiQ/9J3CKAafdWRy3hrCzN8aFA7QR rOsfBOq1fTABcz1NS4SNv3dB5IvKWrMUj6E23fh1TAx1ZGP0JnKoV7KmeZf96iQjA/91YYMMo tX5rrJ8rYUJfmLjQ77jOj8Th4ryYnsu2bRXILI6DlI6I/Y3VJrZ49Zve2wJtyApznH7BUvGjB w7cnnsSiyG+PAseUHpADkolOPOu7IdKVz/+/WRhYM3mcckl3+VKWAUOmMFSjo1xpukWxYIpPt b2TGSas3LEPQGkrXlBZDESQBiCBPjRj3HdSJGcwzyRCScKlDwWZJElxGwQlg1jlbuZVEvpcqq zwr1du1mAqx2JugwF4eFqTKG/TAcPmnWcU1YBCtsHSNLa9lTRFo4gGVlAh5N0Se0RZ6pMCvl8 /xCW467zrrcMwPrlFAkU4ZP9HCOfttI6r0CxkV6L151LNd7EU75WNetP50bs1D3wTsms2gWFd Pygr014/EXszC1QcEJRuLK7eFv9IyxUIPPfzuC/ZeYGoN4dYgcL+wItpwIZwrx+9O36WDgSxo 3N2t4zDBH06HiUQMQn00hWCX4GLhZpNz+T15/lnlkBZpN52keWNw9HRHze+aZQhr0HFSoKoVj ifm6K9Rw7GQXl1gqiiOgwkEymd/ol3vO3t0JvHON6z2WNieeXcSwu42Cv5ftCEt/oGBs2ROfC 7Jw/l9LPVuZGyA2aL4+WwF1zcQb7M4w08vQUMA== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/scsi/bfa/bfa_fcpim.c | 3 ++- drivers/scsi/bfa/bfa_fcpim.h | 4 ++-- drivers/scsi/bfa/bfad_bsg.c | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c index 5f53b3276234..2c85f5b1f9c1 100644 --- a/drivers/scsi/bfa/bfa_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcpim.c @@ -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; diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h index e93921dec347..ec8f863540ae 100644 --- a/drivers/scsi/bfa/bfa_fcpim.h +++ b/drivers/scsi/bfa/bfa_fcpim.h @@ -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) \ diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 72ca2a2e08e2..01fc51a70356 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c @@ -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);