From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A08A2C3A5A6 for ; Thu, 29 Aug 2019 17:03:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7862C23403 for ; Thu, 29 Aug 2019 17:03:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PAXO8ZbC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727763AbfH2RDM (ORCPT ); Thu, 29 Aug 2019 13:03:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39340 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727662AbfH2RDM (ORCPT ); Thu, 29 Aug 2019 13:03:12 -0400 Received: by mail-pf1-f194.google.com with SMTP id y200so2473576pfb.6 for ; Thu, 29 Aug 2019 10:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cT40aX1Rm158dXbZvg7FygLmkaJhPhVyHtqBmt7878E=; b=PAXO8ZbCVqCw0eVBICcj0380noufm8aJLcc22R6FQyST4NWgBmi93l2YHrrW8mL0Bi oytzULxOstEziMDvAjIC/na6bXjIH2Gbhn+UtLkEiHbSzC5zuigdjKWDl5IkU9KNaTHk vNXzdah4WS39Vp4NQH4N7miEiBLnAxdMrpmLI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cT40aX1Rm158dXbZvg7FygLmkaJhPhVyHtqBmt7878E=; b=teN3Mw5EsEPZDOJTbluqwHtTtCzfvmjhY6x78gjuPXCVjj1ZFSKjL3gmNCXgy8hz1r m5+Pwk24F0zqVXvckRg9P8cOkii30aJJnWFkjlT+MHXAg3EZI0O/jrhC0ErZF8wxVFjQ yFuMxVRhIrrkQP389Zd11pSQzqabdGrwfDf+vjEliWa2BfI+8r0xR2h89I9scWyfhMiW s2TiMRGL8NmhO1K/J00Gxn/4t4sSinUmFLJCY1UUlPBE+3p1UYJOCW280ve7woQ47YXi AGi42AboCs7ywNyK5Nu0PhhfoVuUCcelo+ygnOODPEJM50hozIOotuMFsMVUX2TC1KYT dquA== X-Gm-Message-State: APjAAAXAhNdYwbPqknas+lzakHbX6Gtm9xFlCBDrukqBcjXUMeemu/5E Yu3kJSegTOJ+ywyzHUwhigG5rA== X-Google-Smtp-Source: APXvYqx/Q0fFZvZWabn6tcL2I8GORQH9uYo7dBQccjsc+OV6Z3702ta4szivlvQBDGAk0mtwjAaNUQ== X-Received: by 2002:a62:1a45:: with SMTP id a66mr13125850pfa.142.1567098191599; Thu, 29 Aug 2019 10:03:11 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t9sm2671099pgj.89.2019.08.29.10.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 10:03:10 -0700 (PDT) Date: Thu, 29 Aug 2019 10:03:09 -0700 From: Kees Cook To: Mauro Carvalho Chehab Cc: Linux Media Mailing List , Mauro Carvalho Chehab , Andy Walls , Bluecherry Maintainers , Anton Sviridenko , Andrey Utkin , Ismael Luceno , Kyungmin Park , Sylwester Nawrocki , Kukjin Kim , Krzysztof Kozlowski , Stanimir Varbanov , Andy Gross , Andrzej Pietrasiewicz , Jacek Anaszewski , Kamil Debski , Jeongtae Park , Andrzej Hajda , Hans Verkuil , Antti Palosaari , Mike Isely , Greg Kroah-Hartman , Richard Fontana , Thomas Gleixner , Kate Stewart , Colin Ian King , Sakari Ailus , Randy Dunlap , Ezequiel Garcia , "Lad, Prabhakar" , Steve Longerbeam , Nathan Chancellor , Tomasz Figa , Paul Kocialkowski , Boris Brezillon , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 6/7] media: don't do an unsigned int with a 31 bit shift Message-ID: <201908291002.2F67F5ADA@keescook> References: <4a411ba155eb062b6575aba0824123c840806c0b.1566502743.git.mchehab+samsung@kernel.org> <1a78a757b37d2628312e1d56d7a741ba89d42a91.1566502743.git.mchehab+samsung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1a78a757b37d2628312e1d56d7a741ba89d42a91.1566502743.git.mchehab+samsung@kernel.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, Aug 22, 2019 at 04:39:33PM -0300, Mauro Carvalho Chehab wrote: > Doing something like: > > i32 foo = 1, bar; > > bar = foo << 31; > > has an undefined behavior in C, as warned by cppcheck, as we're > shifting a signed integer. > > Instead, force the numbers to be unsigned, in order to solve this > issue. I also recommend using the BIT() macro, which does the ULing correctly, etc. i.e. instead of: - keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0; + keyup = (gpio & ir->mask_keyup) ? 1UL << 31 : 0; use: - keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0; + keyup = (gpio & ir->mask_keyup) ? BIT(31) : 0; -- Kees Cook