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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 6705BC433ED for ; Mon, 17 May 2021 07:35:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 356B2611C2 for ; Mon, 17 May 2021 07:35:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 356B2611C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RePf4ooibnxGNRYrpMCle2iE4Y539dl+2dxWImIsTDk=; b=MAzPBJFDSPMrtj1556ucm265r k2QqoaGgG9ri3AIupCb8QcxaGsQNDyZWbPTNCzs7tHGviovDWi2x2P4yHupFpdFha9H4T/kibWODm fdAiukIk5MKlllS0iz5przC9klfYIYSzYWHlgukVETSkEJgzKOELdBHB8oCUlJvvOnrOcMnmAmtGy BqKJNGsh95RNnS0jrhPfOt75+/veiCLBcRsJY/6qdaqWTKXU+HzCu4ZhQylJUsATDOkU+nme1Gu1W BtEsGCj7aHg3s22P3cXNAYOSr3Mn2TPJztWqDh/X5H5BybaszyQDkC/2QZ1lq/4oGT8m8tWOX+YVC s9YXiwLdQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liXkp-00E34G-OG; Mon, 17 May 2021 07:33:32 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liXkR-00E30T-Fb for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 07:33:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ilXm0XXXBHzYtCnRcId2yjFKjrNgw9mFO9T617JooOE=; b=vzlYKuKN8TVDU4n+PHF9Dl6vSx YBtFsZ0DMz0vOFiK6XRy/CDg/j1+u5p70IR+9X4uRfsfJE77m/95jBBYRfdUSf3RDcbRxDwKI3wns etQWC3/jGkZx6QHHGB7fbmqol5CqNs6tUJaL0M/EQ7lkfLtllZTRIwmseQnbvxZScqK6j6Nj4Qm8N SOrp1pJK+tdlxlVOnc8j8Rm4QJ8ujzIaePlTT7qyAh9EGsK0OqEOZEM2m31pYOpfnFrhIMT14k9eO 8xUuKc51b33VZ3ivSp9s9PY6B+n6yudPcIEgFJ13B09+DIJbqTN5jl2jq6mqvToXeJD2aRow+ScY+ WAwt1ABw==; Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liXkO-00DY3l-BH for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 07:33:06 +0000 IronPort-SDR: kYhEG8Wgwo1LlWpsqs1D3VLGFAQhve2Mp5mDiI3DW5Iy+NjFaGcjoyn0+so2MCpcr4Wgi6t57M 0Bc9W5SLT3+A== X-IronPort-AV: E=McAfee;i="6200,9189,9986"; a="264324662" X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="264324662" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2021 00:33:02 -0700 IronPort-SDR: 5XNFRMKOxEKOdgqb1gfmSSD021Ihgc5ethQIgLe94169a3Skxk2vw8QmA5Xj80R81VOBJR3Ukf UBIvSJ4vBxjg== X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="410714709" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2021 00:32:59 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1liXkG-00Cggg-Re; Mon, 17 May 2021 10:32:56 +0300 Date: Mon, 17 May 2021 10:32:56 +0300 From: Andy Shevchenko To: Colin King Cc: Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Linus Walleij , Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , linux-arm Mailing List , kernel-janitors , Linux Kernel Mailing List Subject: Re: [PATCH][next] gpio: xilinx: Fix potential integer overflow on shift of a u32 int Message-ID: References: <20210513085227.54392-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_003304_449657_3584D92B X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, May 17, 2021 at 10:03:15AM +0300, Andy Shevchenko wrote: > On Thu, May 13, 2021 at 12:12 PM Colin King wrote: > > > > From: Colin Ian King > > > > The left shift of the u32 integer v is evaluated using 32 bit > > arithmetic and then assigned to a u64 integer. There are cases > > where v will currently overflow on the shift. Avoid this by > > casting it to unsigned long (same type as map[]) before shifting > > it. > > > > Addresses-Coverity: ("Unintentional integer overflow") > > Fixes: 02b3f84d9080 ("gpio: xilinx: Switch to use bitmap APIs") > > No, it is a false positive, > > > const unsigned long offset = (bit % BITS_PER_LONG) & BIT(5); > > See above, offset is 0 when BITS_PER_LONG == 32 and 32 when it's equal to 64. Should be read as "...and 0 or 32 when..." > > - map[index] |= v << offset; > > + map[index] |= (unsigned long)v << offset; -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel