Received: by 10.223.176.5 with SMTP id f5csp1138699wra; Wed, 31 Jan 2018 01:47:18 -0800 (PST) X-Google-Smtp-Source: AH8x226LDt35xB3KoNuZHx0NLuUqZ/8Qd7dzI/S/b8/+RuVfr3QrqUwP4G+OCd+T9XlW0Z/NjKne X-Received: by 2002:a17:902:d688:: with SMTP id v8-v6mr28183623ply.302.1517392038338; Wed, 31 Jan 2018 01:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517392038; cv=none; d=google.com; s=arc-20160816; b=sSvc9QNLOAB1QcXeaK0Iwun1FTH3buEbIF0lszescmCF/bY+Oopg1i5F4yW4B9HB29 fWfQM5YkgBG37wKe1yhaRtrnk21sd4JgOddFjteqtQvlPx+UBo8PHvGevT6jz/o5/jCF otLWnfOqwDi2n5HVjjPlAuTk8/ZCvswSSyznQns/MZd+ZqtRW0xyNdMk2lFlEtgoD+wO JvpQvOjzsBsIPspEgDyhU96u3bAzCBSnL91F4dmoo4ZaG8py9LrA93d0+UOi6iMoHZKh iD2952rPJ/wCWtEqaybVWlly2Lt0TPg/Vt467Y4aXD5YQ1veNPgMEe7vqq0sUUYPerPL +bjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=KXff8PO8oolf0e98bHR5P/PGhpBaiVMNyr7qRda4DwQ=; b=Ao4E/jWnQk2U0caR37378WIdHjoxV/wSHiJstLpvuA7jSPb1LpjpW4eOyM7K2YW6xN 64U0uBpm4gW3ZdzyTFSwJSNNqEogd8VgIyk9WXU1FC+ss3cDK1IasIBA/lZyWgCwAis+ Ardf0+8s8S78EiIMm9wA62r6BGeQI8Mk72BnGeiaW/EYj0JYR/RESUSwht1jVYPmSGqN iDPMsq63zCRY4XJEwGB1FlaGfzy1WAhQN4coFlAeVx4jEABdR2S5ean8pt55EWYgvgyJ 1U1DZSkIXktd4mGJlRrNJW9cyopfrS/Bc73SwlbnS01g4ottTKN6RAbBtbPDYDCTXf5j pYBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pe13SVrb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10-v6si12630396plr.317.2018.01.31.01.47.01; Wed, 31 Jan 2018 01:47:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pe13SVrb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbeAaJjS (ORCPT + 99 others); Wed, 31 Jan 2018 04:39:18 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:44972 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753767AbeAaJjK (ORCPT ); Wed, 31 Jan 2018 04:39:10 -0500 Received: by mail-io0-f193.google.com with SMTP id z6so14523783iob.11; Wed, 31 Jan 2018 01:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KXff8PO8oolf0e98bHR5P/PGhpBaiVMNyr7qRda4DwQ=; b=pe13SVrb/ivhHgobWAK0iaqvaHS54pJjE/sM+lSds9yY0E0KAay5LgrI4aRdCFxJn/ l5ZjctF15B1nshR+5fYnAqixJfm9olBP+uOk0qgg5zxeUOOiDur7nmPRfAfd1foGvIm/ cmGDxMCbMMYL2V2CnKLkUqC/oiWO2h2ToZofH5ThNajuby4bGJb8dNUpTv6mU2zcHhGZ AonzT27MFY69Kka8yJCdthHpE9G0RCy55Oug8vaKn0v4ZZTe59lnkFJdaXGzNzPNVtq+ yP+uxw8Vefc5rDE8+RoI7ZkSDmgwmf0YH3EQvbdWcBvIHzzwyEJy7xxM/IlNYIwnpzC4 QC2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KXff8PO8oolf0e98bHR5P/PGhpBaiVMNyr7qRda4DwQ=; b=nm9EdRC4A+umFAT0cnrvAsH9dSPMB2M0wTRTUtxZImdNXFxUOAjiVxKc+R6RSBKPej 0H09OpBt2mQPGf6RRLOm9ZpTag3Uwx02x31TjpH4Uc/3nZF91XDZhUc5THRHE3GnNsAV 6vpJPdtBZi0PZdvmU91N47LZLmF3FWR/pJG1fzNXzqltxbYSi+JVYaG4QojapgB4zrrk mBZVPAsj2Q9/QsFd+u3oztH/BHXndUljEUOj1h0AR2VEUV4NBav9jBzLkYdXmSte9Kal XMMM/gcrqzB+OTZprqpZditY0bs/Tq9DYMr5Izq4Jc96NSw1zQ7IRo2gwxVwXBZnxOrV NRFA== X-Gm-Message-State: AKwxytcllyq4UDLIpFQsvyZNTRb7igrlIbwTx5YwOFHOYQxatJ2pAiuC e1RKs1NhlmxispipSK6CUVMfiLIG9Gbp7hYB8+oIe3Ug X-Received: by 10.107.136.76 with SMTP id k73mr34032655iod.301.1517391549645; Wed, 31 Jan 2018 01:39:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.27.70 with HTTP; Wed, 31 Jan 2018 01:39:09 -0800 (PST) In-Reply-To: <20180131052948.GA16419@embeddedgus> References: <20180131052948.GA16419@embeddedgus> From: Ilya Dryomov Date: Wed, 31 Jan 2018 10:39:09 +0100 Message-ID: Subject: Re: [PATCH] libceph: use 64-bit arithmetic instead of 32-bit To: "Gustavo A. R. Silva" Cc: "Yan, Zheng" , Sage Weil , "David S. Miller" , Ceph Development , netdev , linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 31, 2018 at 6:29 AM, Gustavo A. R. Silva wrote: > 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 */ Hi Gustavo, This (and other u32/u64 issues in this function, is this the only warning?) is fixed in my striping v2 work branch. I wasn't going to push that patch separately, but I guess I should post it. Thanks, Ilya