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: 118580 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8080545qgn; Fri, 10 Nov 2017 07:39:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMZzNpQw8mV3/n4IjifADwHv8masLTWV9EUlrvkapW+5a/dsSeZ0Ycb7XwHjjykXDFPd54we X-Received: by 10.84.218.204 with SMTP id g12mr738441plm.213.1510328355920; Fri, 10 Nov 2017 07:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328355; cv=none; d=google.com; s=arc-20160816; b=jSthk+2wdXxB+/fmDGRcQnWsWrmZNIohdfPClLvaMHlgurMoBNxOOcCb+uyNAQXUKu Aqcgl2cxZ5YhI/iSXjnRWlgl1Dy/d6YnlgJ74vkiL9ggaseStqHzdRXaHvav0l6dNdi1 AqPdq1rl5x46rwUcFTc6lJDe/Ksl/eut0TunPLnowM22+1zdl+V/8fiAJ1OjtSuxj3vA sGfLs76ZE2ckzO+cGssNsfOYMVgY6rCZajb/ETP81Vf1B6Nd+SFaq39mfAX8kCkwR09+ lvMO9biJDxEnLp9q1ky84GkNu54gvwO/UvoZw0oFPtXRn796cX6pZHas4AqrfdBDt6WK V+Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8D5ikj0CAy307xT/SbvxfbVpVL6gEc3oq8i8WhCE9PU=; b=t3KAEZuNKka3a5x0N/ahBzRx6GHLYuqC1pfS/kjHxBXn9aLqU+gZ2ebb05gtDXsJ+i ZY9VLbpM8/I6yVtFoUxIk+8VBJ57KmKeX0BKrVCiO6xIogV5TiIvF3LGkPEa9jHd9dBq MG3qB9/lN4uKp1tUhJDCUdth+eQ+RePmXVZbz4ejWTJr5Qzs5k4Fjj8gLsJ8NbnVU7Nx n0TB5nIoJJ/PWCdAufdJ2yvTYwL1DoXtlwGVHIpWR2ifgei5vjgdghl3LP4b8W3Cok87 P29gZ3vCQwdCfqD/ScJ3472vQzaJg8Xg7dOZ8ZSf60d/lnOcyTZFvVdXw9KGRH2KFogq EtNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si8938346pgs.301.2017.11.10.07.39.15; Fri, 10 Nov 2017 07:39:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753202AbdKJPjP (ORCPT + 1 other); 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 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(-) -- 2.9.0 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);