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.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 A188EC433B4 for ; Mon, 17 May 2021 07:05: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 2F55C610C9 for ; Mon, 17 May 2021 07:05:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F55C610C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/iFwRA9bSS/tFFXRz1iaV9q6XY5UgztYrpXnCSGJtyU=; b=EDdLch8zZqDk7RTU0dMGEv2ID P8KLAWG+o7KwDnlEQzk9F9Q0qESh9uMacs39jNBG6Boi7fQkAPcAzjeDIZMn6E/03OZaQfVl7YOdu k+Wl13iKVA2p2HNPwr/l4ClHDo9+U2VScqktrQovGdNp7ddoMbzCyYXrtDPnGM9kxQBtpG3zvDZVW r5s/CcbOhnj8khbVFuxHGEw1llFdl5OaSsyvhEqMS3GxgqLZWmsnmPA5B2wBD3s/2vLvUzeuhKJEn rdsnoCtUNeXW9Zl1jR2+nO5hP1ThR51NQSuzcUDieGpTXC3x+Sjl36LM8CaguPCbXPLcnDr6QRjOK 58RIjmLxA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liXHw-00DzKE-Ch; Mon, 17 May 2021 07:03:40 +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 1liXHu-00DzK0-DW for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 07:03:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kso+u5oDEUI6hC/TpN6G+VEPeqtVt8JMKDkpe0hvQw4=; b=4qFSgn3P/McuE2jCQpxo3vJhAO QSfluWXS4XIQoZRYEF1T84T6MMTHrgeEei0DxG/5DC1JB78mZsDTmMr3YMF+DAP9P2vyG1inUK5vr 8x6ztSKOnLVZY8uimGemCrHvkB4GxtwFwA67vCvLLwbDqyO18HHal8DoL14P8swjE8mI133qMmUzg 7Vnq6kBOWY6vrN6kgYXazjvS6Vl7bjLgdpt3/G6vpR5rac6V0EOPyAchLBrRsks+z90wyyPFjcr+T spGD39GY5/lah4Ots70Fg7f0/TsPzBKgvuWujlXKlcoPJcAbbt6kHzGmi2ZGATyjmBeuAt8j5dZXN 8pfr/pYw==; Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liXHo-00DX53-Ig for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 07:03:37 +0000 Received: by mail-pj1-x102e.google.com with SMTP id n6-20020a17090ac686b029015d2f7aeea8so4012308pjt.1 for ; Mon, 17 May 2021 00:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kso+u5oDEUI6hC/TpN6G+VEPeqtVt8JMKDkpe0hvQw4=; b=NEbHNwThWEj/g23crYRi7RqFA8QTN7P7vSE8qulvyTyQ6IEA61lbeLgBIMLxpkA5kZ ugEXfzy15FDU6bAn2yycy1il8SfAeERdmFfccsen7A2kODq5Zn/w4FvX3wlsdKrU+8u9 a5RfT7u8xCwzH96fptkWr3fGInei2PDt1l9JfMIdwsktQ2Tl149U+R07krzvwhkl/iY5 HAGionsDO3VG4dnaLIokeyFqrTBmQydqVgclx0qJUoLbm/BQycSSeAHfJF7YkxQPzVz1 IF4DXfGjlsuH2IOQ5ETXDc2Kia28lut6eHhyLpVZzQtXKD2MyEw8puW1psx4VfHsiJ13 SfBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kso+u5oDEUI6hC/TpN6G+VEPeqtVt8JMKDkpe0hvQw4=; b=lvuMAv66ST9uIE2nS6H50Q+YMRCk/zDfFE4k//lYNEXyvfTNlTlQ9F5sIo8RhcJaO0 7dPA4l2k+CjSABYvP+4aNyxId9OWYbkTceBYW/egMaIv8mP6PGdlV6g41HC8nC8X5zwR vrkeyrFw04RXImNdNwv+dHfGMsKH8VN9QhcwXMDUDDThLFDuMAb3Lsb/b3npdQJGlJyZ wIEAhlmFhii8b9PilaM1BEEcDUwUB/F7lbVmAKJaw0cXb2DEdZIEbfFBsS2iAhtikxmv fv0t9bZcc3q1UYdJf1sNCuGPEPy8RHrnogL9cyblEz1cM7E79nq4p71nz8B1nvb5+l/l Pt/A== X-Gm-Message-State: AOAM532P028HJ3dgzG5/EMvnPq6NC5Z21QleeI5YOFXnnDFYx3bWw0DG ocSx5Kkhu8zsFaE9J0DfInh0MAVqGsGwooRy0Ic= X-Google-Smtp-Source: ABdhPJzEYwkmCqhc0PcoCvbscW8cdar0csJ9Ro1rhG3jcTsBopXsi87oK+hq4MY+OFYFMaVphW4HofSxoxS8Snj4u4Q= X-Received: by 2002:a17:90a:d184:: with SMTP id fu4mr1421945pjb.129.1621235011120; Mon, 17 May 2021 00:03:31 -0700 (PDT) MIME-Version: 1.0 References: <20210513085227.54392-1-colin.king@canonical.com> In-Reply-To: <20210513085227.54392-1-colin.king@canonical.com> From: Andy Shevchenko Date: Mon, 17 May 2021 10:03:15 +0300 Message-ID: Subject: Re: [PATCH][next] gpio: xilinx: Fix potential integer overflow on shift of a u32 int To: Colin King Cc: Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , "open list:GPIO SUBSYSTEM" , linux-arm Mailing List , kernel-janitors , Linux Kernel Mailing List X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_000332_635789_4448740F X-CRM114-Status: GOOD ( 11.14 ) 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 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. > - 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