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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D145C433F5 for ; Fri, 4 Feb 2022 04:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=axRSH7ivAVHBL1L2BmUmwJ+JxU9veQ25q9SlhB/2Y90=; b=wezjf3gipz60sR YmwI5R23xwV0/EbXrQ5nULPygaKhxapU9iwd39Mfwh3nEkZilqmI5YVVQfBwbCLPZw/bwjo3nW7OG 4iwdqc+LOJmcrdBxzFxzd/n9Fserodjzo644AZfYBAS5nXpERJ1YGYqXtzUVfzMi3aD5tJ5CKl4dc xFvXBHF0t05uEoVcUlnuKji+F5ZbEIG35Kuh2y6++AgG1S8PTt3bA3U2owrd+bxkUIELZznkavKtZ wbrdH4fLX+CSfnhZtdG1jHHabfmVbfJssB0KeMZIY3O2KO/jRgUHBHk7wqnrZbHv0koSm3xFHNV/3 4OMNVFPxaApV4LDyLt5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFqEF-003SJw-3e; Fri, 04 Feb 2022 04:29:47 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFqEB-003SIk-1r for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 04:29:44 +0000 Received: by mail-il1-x12a.google.com with SMTP id s1so3878986ilj.7 for ; Thu, 03 Feb 2022 20:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wNFwjW4PYcifd9RezG6AJwf0bLCg9aSqyt07d3zX9jU=; b=A1bh1iNcaCgez+6i8g3ApzO/lcs1iqFtK+bb28hHm1PubPk8Xff+pshB7YqMSSQ07V kzE1uGH6FPhjXt0UhfWmLyOl+LW03GQ2jFA+JEGZI+WxDopjc0PPJ1rm1XYgtyr9iNbE U17xDXckyZcyme4qKTLCUrI/c9Ptu5W9dHegB2oM6VUH8WS5Yx2sBrSKLiHCEeVUJWW6 FRQWrE1w+wqGtY9cKCH0r6qo/9YE4FXO9xgWG58jsMg89vIbLa5+Oik+WG+Gk4hVwmL1 ePjpm9zU3D8nnAbfRB1B6SnGnNNOSi43iat3hLxNoGDh7QgsLxhemT1ILFYLCwDG1OyB Yeaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wNFwjW4PYcifd9RezG6AJwf0bLCg9aSqyt07d3zX9jU=; b=YwdmZkyVm5KJfuqWiNQ1p2xeG///tCRHx7DJ7uFjmI1iUprUo2a8bho3VsrfDDBW5P zjHNPras5N3Pl3PMMErLDauodLjSNNpdSjVBajlHVjLKDjOiQ3a8RAKH+MUK6VVMP+j1 MtNeypBtxnkEuMK/lIQligmTbUs1M6XRtV7z0IX5x/qGNXlrB6i2jhcK6XGDG31KDKrU /ZsvHWDUpj4a6Z3fc+5IYqs7UTnFyP8QyKLLMpx7qbTcQusaZFjBnSXrhDvlptz4wQbY Dp05E1Es7ZMHNvyeHOhe1NV7t9E3hrLPDeXknfKgTZWOpzfCBeHIMgtIf5GE6fYEW7fh rW0g== X-Gm-Message-State: AOAM5332KYeEj5R+qT8fz3j964sB+2hK3kNL1OFXcHZ5RJ40hxl/aeBw 3p8np5zXc06zzINWxD3KxZs= X-Google-Smtp-Source: ABdhPJxCbimJKBDAGULxMpWI6Z/Oeyi6vPWsPUhcgDxbxxP9J7AvhHop0RwDzDiwvR/bCVL4Mj5CJA== X-Received: by 2002:a92:680b:: with SMTP id d11mr588761ilc.74.1643948981266; Thu, 03 Feb 2022 20:29:41 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id m1sm459683ilu.87.2022.02.03.20.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 20:29:40 -0800 (PST) Date: Thu, 3 Feb 2022 20:29:38 -0800 From: Yury Norov To: Kees Cook Cc: Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] iio: stmpe-adc: Use correctly sized arguments for bit field Message-ID: References: <20211215232513.2070158-1-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211215232513.2070158-1-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_202943_118978_890BB8EA X-CRM114-Status: GOOD ( 22.27 ) 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 Wed, Dec 15, 2021 at 03:25:13PM -0800, Kees Cook wrote: > The find.h APIs are designed to be used only on unsigned long arguments. > This can technically result in a over-read, but it is harmless in this > case. Regardless, fix it to avoid the warning seen under -Warray-bounds, > which we'd like to enable globally: > > In file included from ./include/linux/bitmap.h:9, > from ./include/linux/cpumask.h:12, > from ./arch/x86/include/asm/cpumask.h:5, > from ./arch/x86/include/asm/msr.h:11, > from ./arch/x86/include/asm/processor.h:22, > from ./arch/x86/include/asm/cpufeature.h:5, > from ./arch/x86/include/asm/thread_info.h:53, > from ./include/linux/thread_info.h:60, > from ./arch/x86/include/asm/preempt.h:7, > from ./include/linux/preempt.h:78, > from ./include/linux/spinlock.h:55, > from ./include/linux/swait.h:7, > from ./include/linux/completion.h:12, > from drivers/iio/adc/stmpe-adc.c:10: > drivers/iio/adc/stmpe-adc.c: In function 'stmpe_adc_probe': > ./include/linux/find.h:98:23: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds] > 98 | val = *addr | ~GENMASK(size - 1, offset); > | ^~~~~ > drivers/iio/adc/stmpe-adc.c:258:13: note: while referencing 'norequest_mask' > 258 | u32 norequest_mask = 0; > | ^~~~~~~~~~~~~~ > > Signed-off-by: Kees Cook > --- > drivers/iio/adc/stmpe-adc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c > index fba659bfdb40..d2d405388499 100644 > --- a/drivers/iio/adc/stmpe-adc.c > +++ b/drivers/iio/adc/stmpe-adc.c > @@ -256,6 +256,7 @@ static int stmpe_adc_probe(struct platform_device *pdev) > struct stmpe_adc *info; > struct device_node *np; > u32 norequest_mask = 0; > + unsigned long bits; > int irq_temp, irq_adc; > int num_chan = 0; > int i = 0; > @@ -309,8 +310,8 @@ static int stmpe_adc_probe(struct platform_device *pdev) > > of_property_read_u32(np, "st,norequest-mask", &norequest_mask); > > - for_each_clear_bit(i, (unsigned long *) &norequest_mask, > - (STMPE_ADC_LAST_NR + 1)) { > + bits = norequest_mask; This would not work on 64-bit BE architecture. It should use bitmap_from_arr32() > + for_each_clear_bit(i, &bits, (STMPE_ADC_LAST_NR + 1)) { > stmpe_adc_voltage_chan(&info->stmpe_adc_iio_channels[num_chan], i); > num_chan++; > } > -- > 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel