Received: by 10.223.176.5 with SMTP id f5csp4198411wra; Tue, 30 Jan 2018 03:44:46 -0800 (PST) X-Google-Smtp-Source: AH8x225omim86KZVZZJkR1XCbjiqDJB6+2yse9UTawuapCzgaDG3RCyFjvQya3bcij/3Xhb4xpCo X-Received: by 2002:a17:902:4e25:: with SMTP id f34-v6mr15445130ple.68.1517312686318; Tue, 30 Jan 2018 03:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517312686; cv=none; d=google.com; s=arc-20160816; b=lw8hVTavuDFM4XWvOcDBd9bqR6kZLnfwGc3eohzBRsZHBEEMkSfy2Lv5ND/OvFAFcg Ba0um9f/LPcUgpCYVZ6eLECkQsw3dZapqFqg+Tl6vV2y6QolBW0OmB8EylHTYbWU8B0y VUaT+HI5hJVWVniSXMYmarxOmhMKkLGYNJNV8JnwQXhV/eWag6rvmNH67hi4kVE8l3ZB xf2Nx0piA+s9+k5M8itipoTTDpJjug87AL9K/6DmuBnBiOs48w1z1kDxdhRWKctY0wip cyp63zfNvqZR5LCw6Hh+EcamV8R6ijiaIiB9+lBmWO3ZWZmUCotFlxkP4rB9xxMlxLVY C/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :user-agent:in-reply-to:references:subject:cc:to:from:message-id :date:arc-authentication-results; bh=eRYBF4LATVqEgbHQ/26036erl6WxhvTyhRRZes7Fg+o=; b=oIcL4VSK554FcGIUZeHuquFILicJIps0Jb91u0IVtaVWF4Ekeg3XKZCJVmFKpe0Wgi /A+bNt4Vrq9IkzSg5qpPxhd3P949UKPllXCjEF+TdkfHhv7TISGVt+7WnPIoDUqmDQIm 2E+8QDIHHoVwWvvUTroBOv+ArkwlIK/71oERmjEopFjVKKbLQEHD5RRXCZ0fHd8cG6s6 Ec9TKKKGN4n8AAXvsKHyW1/kSruOxl8ZNwUFNgvLP6QbbSpwzwNlpUir4653tTi2XlCQ yuQx/oLQh1NKL5umgSOjRHpdO3a0tUKO1oHhbZocp9EF4VsAn5/N5nQyPaas/ZqJdvJW 3IuQ== 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 b33-v6si11499934plb.750.2018.01.30.03.44.32; Tue, 30 Jan 2018 03:44:46 -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; 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 S1751628AbeA3Lnx (ORCPT + 99 others); Tue, 30 Jan 2018 06:43:53 -0500 Received: from gateway22.websitewelcome.com ([192.185.47.179]:28767 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbeA3Lnu (ORCPT ); Tue, 30 Jan 2018 06:43:50 -0500 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 2E44D123C6 for ; Tue, 30 Jan 2018 05:43:50 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id gUKMeOfgXzzFjgUKMe3ZQy; Tue, 30 Jan 2018 05:43:50 -0600 Received: from gator4166.hostgator.com ([108.167.133.22]:34986) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1egUKL-00344M-Rj; Tue, 30 Jan 2018 05:43:49 -0600 Received: from 189.152.201.65 ([189.152.201.65]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Tue, 30 Jan 2018 05:43:48 -0600 Date: Tue, 30 Jan 2018 05:43:48 -0600 Message-ID: <20180130054348.Horde.dj9qH83FlLTXD4Y59GxgcMB@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Hans Verkuil Cc: "Gustavo A. R. Silva" , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] platform: vivid-cec: fix potential integer overflow in vivid_cec_pin_adap_events References: <00eea53890802b679c138fc7f68a0f162261d95c.1517268668.git.gustavo@embeddedor.com> <2e1afa55-d214-f932-4ba7-2e21f6a2cd3d@xs4all.nl> <20180130025141.Horde.h4aoQSwrqdPlpFtSKtB9DuS@gator4166.hostgator.com> <43652014-30af-1e4b-c0a9-c23f9633fb2f@xs4all.nl> <20180130045545.Horde.1SSKgcFKaDeoUtmczJ8SRH1@gator4166.hostgator.com> <3efaaf36-8edb-d899-b89d-902ba1bc63a6@xs4all.nl> In-Reply-To: <3efaaf36-8edb-d899-b89d-902ba1bc63a6@xs4all.nl> User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline 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: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1egUKL-00344M-Rj X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:34986 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Hans Verkuil : [...] >>> What happens if you do: ((u64)CEC_TIM_START_BIT_TOTAL + >>> >>> I think that forces everything else in the expression to be evaluated >>> as u64. >>> >> >> Well, in this case the operator precedence takes place and the >> expression len * 10 * CEC_TIM_DATA_BIT_TOTAL is computed first. So the >> issue remains the same. >> >> I can switch the expressions as follows: >> >> (u64)len * 10 * CEC_TIM_DATA_BIT_TOTAL + CEC_TIM_START_BIT_TOTAL > > What about: > > 10ULL * len * ... > Yeah, I like it. >> >> and avoid the cast in the middle. >> >> What do you think? > > My problem is that (u64)len suggests that there is some problem with len > specifically, which isn't true. > That's a good point. Actually, I think the same applies for the rest of the patch series. Maybe it is a good idea to send a v2 of the whole patchset with that update. >> >>> It definitely needs a comment that this fixes a bogus Coverity report. >>> >> >> I actually added the following line to the message changelog: >> Addresses-Coverity-ID: 1454996 ("Unintentional integer overflow") > > That needs to be in the source, otherwise someone will remove the > cast (or ULL) at some time in the future since it isn't clear why > it is done. And nobody reads commit logs from X years back :-) > You're right. I thought you were talking about the changelog. And unless you think otherwise, I think there is no need for any additional code comment if the update you suggest is applied: len * 10ULL * CEC_TIM_DATA_BIT_TOTAL Thanks -- Gustavo