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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 3B940C433B4 for ; Thu, 13 May 2021 09:12:01 +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 A12F961420 for ; Thu, 13 May 2021 09:12:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A12F961420 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.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:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iA712Buf8ofyyQ/WnA5nJ4VoshRwzbop5NMMFXiV8pI=; b=MBH/0AvGs+rJZ9ieGLxu8CSTu m1dwXfnAI+LQKrFACcZN+cOG3poRqhdKCcBLMdtuQblza2Mp7jl9AFYMcjzWnvr1rKQSUAyTdmWeX Noepp1Y2B3SYUN6D9zLJqVPrT6fr/wlDN2IF3PcDjcSQf3tW82wrWPHOytvDgq14XWikjHEcgEQRD hBZfT+sm7x6uDT5WiRmhNkDCqek6dJ45BBQKHAuUvRQDucCdbnyCAjmG2TdUT8pHQnihezz3Inrfv ZbFZ7FO+xaRdpQlupSv+FMG9Ig2PTwrVvJXiKCf25TPWGUazm+Vrnxg+Ai0vrob5mIKvE+0gam938 Z5sc5qouQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lh7MJ-005CuU-Iq; Thu, 13 May 2021 09:10:19 +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 1lh7MI-005CuH-5Z for linux-arm-kernel@desiato.infradead.org; Thu, 13 May 2021 09:10:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:In-Reply-To:References:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=ggKbHY5cgatiWHNxQ4APN2kuzPhZSjrjYLmn/G2gfVY=; b=zVvr2FSX/t2IKTMyPya9iF2Boa o5TPJb2cpkOIQJcRQ4y+V8FyUX4G01R2qfLgwF0fHZEQ01/XtIw43vTupNQqhd9iJaQBSge01tf0z LU6CzTSB7GiCvBdPkegdhLOJkcRSYarK7tJ6mmv8mxCDU1A2dTGobN44oWcKUSgXl3Yb/f/oIc06V T7srYk0o7G0qIcgbk1I8uPi31Mr812v5bQVGB1MMPGmeQ9XtOdaNro3aHn/X6YPULADK4iJiX+gZU JtXlNEayngHTXz3eDkxzrSIgbTJe3/Y13q8i9y58GzMgPTjmztaZf5TkPQqcS6rLmRlXhneFgwixF miToSkuA==; Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh7MF-00B7vt-3j for linux-arm-kernel@lists.infradead.org; Thu, 13 May 2021 09:10:16 +0000 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mtapsc-4-O-l6zddbOw-DLiJ4G39p_w-1; Thu, 13 May 2021 10:10:08 +0100 X-MC-Unique: O-l6zddbOw-DLiJ4G39p_w-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 13 May 2021 10:10:07 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.015; Thu, 13 May 2021 10:10:07 +0100 From: David Laight To: 'Colin King' , Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , "linux-gpio@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH][next] gpio: xilinx: Fix potential integer overflow on shift of a u32 int Thread-Topic: [PATCH][next] gpio: xilinx: Fix potential integer overflow on shift of a u32 int Thread-Index: AQHXR9VSZMAtotrvl0OPmMzLRkGfrKrhHwxw Date: Thu, 13 May 2021 09:10:07 +0000 Message-ID: References: <20210513085227.54392-1-colin.king@canonical.com> In-Reply-To: <20210513085227.54392-1-colin.king@canonical.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210513_021015_461861_9658067B X-CRM114-Status: GOOD ( 15.20 ) 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 From: Colin King > Sent: 13 May 2021 09:52 > > 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") > Signed-off-by: Colin Ian King > --- > drivers/gpio/gpio-xilinx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > index 109b32104867..164a3a5a9393 100644 > --- a/drivers/gpio/gpio-xilinx.c > +++ b/drivers/gpio/gpio-xilinx.c > @@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v) > const unsigned long offset = (bit % BITS_PER_LONG) & BIT(5); > > map[index] &= ~(0xFFFFFFFFul << offset); > - map[index] |= v << offset; > + map[index] |= (unsigned long)v << offset; > } That code looks dubious on 32bit architectures. I don't have 02b3f84d9080 in any of my source trees. But that patch may itself be very dubious. Since the hardware requires explicit bits be set, relying on the bitmap functions seems pointless and possibly wrong. Clearly they cause additional problems because they use long[] and here the code needs u32[]. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel