From patchwork Fri Jun 2 18:20:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 9763179 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 5F99C60360 for ; Fri, 2 Jun 2017 18:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57A31285A0 for ; Fri, 2 Jun 2017 18:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AB68285BD; Fri, 2 Jun 2017 18:20:24 +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 E2892285A0 for ; Fri, 2 Jun 2017 18:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750918AbdFBSUI (ORCPT ); Fri, 2 Jun 2017 14:20:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:39470 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750807AbdFBSUH (ORCPT ); Fri, 2 Jun 2017 14:20:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6C5AEABF2 for ; Fri, 2 Jun 2017 18:20:06 +0000 (UTC) To: linux-xfs From: Jeff Mahoney Subject: [PATCH] fsr: fix uninitialized fs usage after timeout Message-ID: Date: Fri, 2 Jun 2017 14:20:04 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the main loop of fsrallfs, we exit when we've hit the timeout but we increment fs before we get there. If we're operating on the last file system in the array, we'll hit an uninitialized fsdesc and crash in fsrall_cleanup. Signed-off-by: Jeff Mahoney --- fsr/xfs_fsr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 517b75f0..e695c243 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -598,7 +598,7 @@ fsrallfs(char *mtab, int howlong, char *leftofffile) signal(SIGTERM, aborter); /* reorg for 'howlong' -- checked in 'fsrfs' */ - while (endtime > time(0)) { + for (; endtime > time(0); fs->npass++, fs++) { pid_t pid; if (fs == fsend) fs = fsbase; @@ -629,8 +629,6 @@ fsrallfs(char *mtab, int howlong, char *leftofffile) break; } startino = 0; /* reset after the first time through */ - fs->npass++; - fs++; } fsrall_cleanup(endtime <= time(0)); }