From patchwork Wed Jan 31 05:29:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10193263 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 F00B1601A0 for ; Wed, 31 Jan 2018 05:50:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1556283AE for ; Wed, 31 Jan 2018 05:50:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5A282846D; Wed, 31 Jan 2018 05:50:10 +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=-5.6 required=2.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET,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 4C9DF283AE for ; Wed, 31 Jan 2018 05:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbeAaFuH (ORCPT ); Wed, 31 Jan 2018 00:50:07 -0500 Received: from gateway31.websitewelcome.com ([192.185.143.234]:13132 "EHLO gateway31.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbeAaFuH (ORCPT ); Wed, 31 Jan 2018 00:50:07 -0500 X-Greylist: delayed 1214 seconds by postgrey-1.27 at vger.kernel.org; Wed, 31 Jan 2018 00:50:06 EST Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 0F2D138AD9 for ; Tue, 30 Jan 2018 23:29:52 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id gkxzeHP37vkfxgky0elhe2; Tue, 30 Jan 2018 23:29:52 -0600 Received: from [189.152.201.65] (port=56046 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1egkxz-002zhY-J3; Tue, 30 Jan 2018 23:29:51 -0600 Date: Tue, 30 Jan 2018 23:29:48 -0600 From: "Gustavo A. R. Silva" To: Ilya Dryomov , "Yan, Zheng" , Sage Weil , "David S. Miller" Cc: ceph-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] libceph: use 64-bit arithmetic instead of 32-bit Message-ID: <20180131052948.GA16419@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.201.65 X-Source-L: No X-Exim-ID: 1egkxz-002zhY-J3 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.201.65]:56046 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 5 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cast objsetno to u64 in order to give the compiler complete information about the proper arithmetic to use. Notice that this variable is used in a context that expects an expression of type u64 (64 bits, unsigned). The expression objsetno * sc + stripepos is currently being evaluated using 32-bit arithmetic. In general, the use of incorrect arithmetic has security implications. Addresses-Coverity-ID: 200686 Signed-off-by: Gustavo A. R. Silva --- net/ceph/osdmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 0da27c6..58dc965 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -2183,7 +2183,7 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, stripepos = bl % sc; objsetno = stripeno / su_per_object; - *ono = objsetno * sc + stripepos; + *ono = (u64)objsetno * sc + stripepos; dout("objset %u * sc %u = ono %u\n", objsetno, sc, (unsigned int)*ono); /* *oxoff = *off % layout->fl_stripe_unit; # offset in su */