Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp504341imm; Wed, 4 Jul 2018 00:39:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYMMHnWubTbdJPoQjRwwjlFtSCvhM8EFYSTQhJquL4jNM5uVKIqiel0rgIsZUB44dil7xA X-Received: by 2002:a62:4ece:: with SMTP id c197-v6mr1041474pfb.240.1530689965247; Wed, 04 Jul 2018 00:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530689965; cv=none; d=google.com; s=arc-20160816; b=K9WCGvVgeCgDRh6JpWRyeTCYqelKjG7e7thSzJibugNhunH7pQQtR3bht7UPvoNxZ8 vtO2TRnGCj6j5CHGk59H2eZy2MG9/4cIA3azZfpoyRcJI0Sz0+n5KfPYrIzmfC7gjcmq IUGQo++zDCcBaX2z+JhJ0XaajID+4BtShOUni6+Rh6YiGPhv1UJBiLAYyFULwBy4afz0 BenWwx4Ybmw2++flBKMhQtitGddTbilAZHJBtr1HZgtrgn4uYccqaf0aLeUKhlVSt115 Zbltjtr3QYyiiR+A4iSZ4J32kAbVfXQFbdApQbxDdRSjGIcVwGcpS3BD25OAmoim+8dK rB1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=KM/dVLstoX09YBLBQcI0vNh4FcB3Gc8PBfkGPiJlK7k=; b=KIBysi+nExgBeZ4FJMD2ifFU5Yk7IfsVYeQlGi/9bi3RXq15Lnx6DiVSiZfEThxhSh YDI1fyjQXALDC/AeAp+OPAfHm6pMIPyo2VIqSGPpltEGeRjPJsswQ6a0q3wSKSlI14t9 6yjHCNF3tyyoubDce+m/9xxBqA8hgd98aa0fh7Lg3mEggxSm77RH8ZLzyEO26g/xPBxk pIb079wLnAd474Ok4NJzUt98/NU7m65JK6g9dHj3FKLHQcbmb2SmsRkR9k07TLGXYU8G ovCuc9pwdbs96KTrxUBhfMJEU917bsqu1wBBUKpFASOxGly+FHyprx9FosIPTNUVHPfz ZmSg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k184-v6si2761587pge.209.2018.07.04.00.39.10; Wed, 04 Jul 2018 00:39:25 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933759AbeGDHi1 (ORCPT + 99 others); Wed, 4 Jul 2018 03:38:27 -0400 Received: from mail.netline.ch ([148.251.143.178]:60295 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932467AbeGDHiY (ORCPT ); Wed, 4 Jul 2018 03:38:24 -0400 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 268CC2A6048; Wed, 4 Jul 2018 09:38:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id bfjoqku6RWhm; Wed, 4 Jul 2018 09:38:21 +0200 (CEST) Received: from thor (252.228.127.176.dynamic.wline.res.cust.swisscom.ch [176.127.228.252]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 464AA2A6045; Wed, 4 Jul 2018 09:38:21 +0200 (CEST) Received: from localhost ([::1]) by thor with esmtp (Exim 4.91) (envelope-from ) id 1facMm-0004QL-L8; Wed, 04 Jul 2018 09:38:20 +0200 Subject: Re: [PATCH] drm/amd/display/dc/dce: Fix multiple potential integer overflows To: "Gustavo A. R. Silva" , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "David (ChunMing) Zhou" , David Airlie Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20180704011305.GA15742@embeddedor.com> From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Openpgp: preference=signencrypt Autocrypt: addr=michel@daenzer.net; prefer-encrypt=mutual; keydata= xsDiBDsehS8RBACbsIQEX31aYSIuEKxEnEX82ezMR8z3LG8ktv1KjyNErUX9Pt7AUC7W3W0b LUhu8Le8S2va6hi7GfSAifl0ih3k6Bv1Itzgnd+7ZmSrvCN8yGJaHNQfAevAuEboIb+MaVHo 9EMJj4ikOcRZCmQWw7evu/D9uQdtkCnRY9iJiAGxbwCguBHtpoGMxDOINCr5UU6qt+m4O+UD /355ohBBzzyh49lTj0kTFKr0Ozd20G2FbcqHgfFL1dc1MPyigej2gLga2osu2QY0ObvAGkOu WBi3LTY8Zs8uqFGDC4ZAwMPoFy3yzu3ne6T7d/68rJil0QcdQjzzHi6ekqHuhst4a+/+D23h Za8MJBEcdOhRhsaDVGAJSFEQB1qLBACOs0xN+XblejO35gsDSVVk8s+FUUw3TSWJBfZa3Imp V2U2tBO4qck+wqbHNfdnU/crrsHahjzBjvk8Up7VoY8oT+z03sal2vXEonS279xN2B92Tttr AgwosujguFO/7tvzymWC76rDEwue8TsADE11ErjwaBTs8ZXfnN/uAANgPM0jTWljaGVsIERh ZW56ZXIgPG1pY2hlbEBkYWVuemVyLm5ldD7CXgQTEQIAHgUCQFXxJgIbAwYLCQgHAwIDFQID AxYCAQIeAQIXgAAKCRBaga+OatuyAIrPAJ9ykonXI3oQcX83N2qzCEStLNW47gCeLWm/QiPY jqtGUnnSbyuTQfIySkLOwE0EOx6FRRAEAJZkcvklPwJCgNiw37p0GShKmFGGqf/a3xZZEpjI qNxzshFRFneZze4f5LhzbX1/vIm5+ZXsEWympJfZzyCmYPw86QcFxyZflkAxHx9LeD+89Elx bw6wT0CcLvSv8ROfU1m8YhGbV6g2zWyLD0/naQGVb8e4FhVKGNY2EEbHgFBrAAMGA/0VktFO CxFBdzLQ17RCTwCJ3xpyP4qsLJH0yCoA26rH2zE2RzByhrTFTYZzbFEid3ddGiHOBEL+bO+2 GNtfiYKmbTkj1tMZJ8L6huKONaVrASFzLvZa2dlc2zja9ZSksKmge5BOTKWgbyepEc5qxSju YsYrX5xfLgTZC5abhhztpcJGBBgRAgAGBQI7HoVFAAoJEFqBr45q27IAlscAn2Ufk2d6/3p4 Cuyz/NX7KpL2dQ8WAJ9UD5JEakhfofed8PSqOM7jOO3LCA== Message-ID: Date: Wed, 4 Jul 2018 09:38:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180704011305.GA15742@embeddedor.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-07-04 03:13 AM, Gustavo A. R. Silva wrote: > Add suffix ULL to constant 5 and cast variables target_pix_clk_khz and > feedback_divider to uint64_t in order to avoid multiple potential integer > overflows and give the compiler complete information about the proper > arithmetic to use. > > Notice that such constant and variables are used in contexts that > expect expressions of type uint64_t (64 bits, unsigned). The current > casts to uint64_t effectively apply to each expression as a whole, > but they do not prevent them from being evaluated using 32-bit > arithmetic instead of 64-bit arithmetic. > > Also, once the expressions are properly evaluated using 64-bit > arithmentic, there is no need for the parentheses that enclose > them. > > Addresses-Coverity-ID: 1460245 ("Unintentional integer overflow") > Addresses-Coverity-ID: 1460286 ("Unintentional integer overflow") > Addresses-Coverity-ID: 1460401 ("Unintentional integer overflow") > Fixes: 4562236b3bc0 ("drm/amd/dc: Add dc display driver (v2)") > Signed-off-by: Gustavo A. R. Silva > > [...] > > @@ -145,8 +145,8 @@ static bool calculate_fb_and_fractional_fb_divider( > * of fractional feedback decimal point and the fractional FB Divider precision > * is 2 then the equation becomes (ullfeedbackDivider + 5*100) / (10*100))*/ > > - feedback_divider += (uint64_t) > - (5 * calc_pll_cs->fract_fb_divider_precision_factor); > + feedback_divider += 5UL * > + calc_pll_cs->fract_fb_divider_precision_factor; This should be 5ULL, as the commit log says, otherwise it's still only 32 bits on 32-bit platforms. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer