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 C7646C433F5 for ; Thu, 16 Dec 2021 13:03:32 +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:MIME-Version:References:In-Reply-To: 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=ssw5cXkT5eoNduC/KIL1Nnzoxi4sV8NxobErqhs8WDg=; b=TPSM72Mp/QdIpu HzuLJ1hvaxRfDjsnlrAPtTRagmuq45K7Y3W5aOWPMftXSHyt3ORNvTcwc+KEbE5W6JzBaeqEqkJN8 FnHmf4/sCFJPCFH8dBaltl9ldqBcegwEJcwxWjLKHWQc0Lch4LThwhQN+Cf2zdRWsVlQmXefg5yDy Fd1Ur7pOiPAcpUkVZKHhOSFV+6XP6R1H9bMTapFxoh1lpHzM2un93t3Va03s4zi+SuhpL1N+tiNfL JK6UnRvzbmcXXg0WyVQTCp2PakIZMTgFgyDmOdlDp/dWlzUP4L+U1npLsW0Sb2IMp4MOKbd9te/Iq qJiVvLrl7Qlk527o6Ubw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxqOZ-005bdn-CH; Thu, 16 Dec 2021 13:02:03 +0000 Received: from haggis.mythic-beasts.com ([2a00:1098:0:86:1000:0:2:1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxpun-005Rct-QL for linux-arm-kernel@lists.infradead.org; Thu, 16 Dec 2021 12:31:19 +0000 Received: from [81.101.6.87] (port=52570 helo=jic23-huawei) by haggis.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mxpuh-0005Cz-Dz; Thu, 16 Dec 2021 12:31:11 +0000 Date: Thu, 16 Dec 2021 12:36:27 +0000 From: Jonathan Cameron To: Kees Cook Cc: Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , Yury Norov , 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: <20211216123615.3e311c2b@jic23-huawei> In-Reply-To: <20211215232513.2070158-1-keescook@chromium.org> References: <20211215232513.2070158-1-keescook@chromium.org> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-BlackCat-Spam-Score: 19 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211216_043117_916696_11083F72 X-CRM114-Status: GOOD ( 19.97 ) 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, 15 Dec 2021 15:25:13 -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 Applied to the togreg branch of iio.git and pushed out as testing to let 0-day have a first poke at it. I took the view this one was trivial, but if anyone else wants to add tags there will be a few days before this goes out in a form I'm not happy to rebase. Thanks, Jonathan > --- > 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; > + 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++; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel