From patchwork Thu Jun 29 17:10:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 9817429 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 AC08D6020A for ; Thu, 29 Jun 2017 17:10:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 943D728820 for ; Thu, 29 Jun 2017 17:10:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 852C028844; Thu, 29 Jun 2017 17:10:08 +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 2DAC228820 for ; Thu, 29 Jun 2017 17:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673AbdF2RKH (ORCPT ); Thu, 29 Jun 2017 13:10:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48368 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbdF2RKH (ORCPT ); Thu, 29 Jun 2017 13:10:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89B1470D81; Thu, 29 Jun 2017 17:10:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 89B1470D81 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=billodo@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 89B1470D81 Received: from localhost.localdomain.com (ovpn-121-88.rdu2.redhat.com [10.10.121.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17F98179C4; Thu, 29 Jun 2017 17:10:06 +0000 (UTC) From: Bill O'Donnell To: linux-xfs@vger.kernel.org Cc: sandeen@sandeen.net Subject: [PATCH] xfs_spaceman: fix potential overflowing expression in trim_f() Date: Thu, 29 Jun 2017 12:10:05 -0500 Message-Id: <20170629171005.9886-1-billodo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Jun 2017 17:10:06 +0000 (UTC) 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 Prevent the potential overflow in expression calculating offset in trim_f(() by casting the first variable to off64_t (64bit signed). Detected by CoverityScan, CID#1413771 Integer handling issues (OVERFLOW_BEFORE_WIDEN) Signed-off-by: Bill O'Donnell Reviewed-by: Darrick J. Wong --- spaceman/trim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spaceman/trim.c b/spaceman/trim.c index 872f68d3..6df9e6a9 100644 --- a/spaceman/trim.c +++ b/spaceman/trim.c @@ -77,7 +77,7 @@ trim_f( length = cvtnum(file->geom.blocksize, file->geom.sectsize, argv[optind + 1]); } else if (agno) { - offset = agno * file->geom.agblocks * file->geom.blocksize; + offset = (off64_t)agno * file->geom.agblocks * file->geom.blocksize; length = file->geom.agblocks * file->geom.blocksize; } else { offset = 0;