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 8E72DC04FFE for ; Tue, 30 Apr 2024 00:04:54 +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:Date:To:Cc:From:Subject:References: In-Reply-To:MIME-Version:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xouk1tNyaOVlB9fYLEdnkvl/tFz+4avGzwhK1CDYd9o=; b=EBCL5Gqm/w0358 A9/wjL5S1xpqPojEijyUDK0MB8AYaokw7WimTCQsTEGodajepaaqoeYaiRTnVSFxEThiY19udTEBy WBLmdYzQ2+uSQOHH+CDmUtJZToWBowmdA2mShY6rx8GHOzn4B/aSBioY9ohEesbK1N1ZBgwmUYlGh KVgGR1j71YZnb/mCDQ4hpur8SWit5nVPSlghBdZLlPWzaCeRRA3JXRb7Wi6pU4iRmq33EaC6ACHn/ PkD6+DLQXL7eY6qbdP+95GoFPR9aVJTh4Fs22BGzlsp9+tMcqNqVPurm7JLdLYGfjtCmMfYW7DvEq cqspYKxGezooIzSo8y+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1azG-00000004WpX-0bN8; Tue, 30 Apr 2024 00:04:46 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1azD-00000004Wof-1JXC; Tue, 30 Apr 2024 00:04:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 19232CE01DD; Tue, 30 Apr 2024 00:04:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CBB5C113CD; Tue, 30 Apr 2024 00:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714435480; bh=GjF585A07WLRSmFByqx2QGzcXnlbaXpuxWaDW/GAdTk=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=ECnO2WuGKFYNALJk4sMtwyo0AqDmnYReBr4XRCtpP+iJJVutqsk+7cR3IiaYPi4i5 f0BFqtfTR2MgBmSxBhsuCnI1u4IIam2OrSP81cO9Aey7bGKmwnYzINimmH+k2EAZ/A MKndRoZv/zxZhgPMnlkialUVwKTjUJSYfnuvC9Kd1MytqlYUVilqPoQL0rvcvLkYgl oo41ZcfPBZ21G0YplGjlXtJlQVbjlxXRTwlA8kFuigG2dsebutbkj2w7JQMVDWuZL/ 8vQ5XBk62p/4VMCsF4fqv0GWDiWu2giTbRKJvarwGbv81ncJ9A1jwzxgQtLP/xr69t JXdqugmLV5ovQ== Message-ID: <38cfd1c4b7297515539bd2c91b3bf541.sboyd@kernel.org> MIME-Version: 1.0 In-Reply-To: <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-1-e2db3b82d5ef@kernel.org> References: <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-0-e2db3b82d5ef@kernel.org> <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-1-e2db3b82d5ef@kernel.org> Subject: Re: [PATCH 1/2] clk: bcm: dvp: Assign ->num before accessing ->hws From: Stephen Boyd Cc: Kees Cook , Gustavo A. R. Silva , bcm-kernel-feedback-list@broadcom.com, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, patches@lists.linux.dev, llvm@lists.linux.dev, stable@vger.kernel.org, Nathan Chancellor To: Florian Fainelli , Michael Turquette , Nathan Chancellor Date: Mon, 29 Apr 2024 17:04:37 -0700 User-Agent: alot/0.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_170443_626919_5D2F92D4 X-CRM114-Status: GOOD ( 10.68 ) 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 Quoting Nathan Chancellor (2024-04-25 09:55:51) > Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with > __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' > with __counted_by, which informs the bounds sanitizer about the number > of elements in hws, so that it can warn when hws is accessed out of > bounds. As noted in that change, the __counted_by member must be > initialized with the number of elements before the first array access > happens, otherwise there will be a warning from each access prior to the > initialization because the number of elements is zero. This occurs in > clk_dvp_probe() due to ->num being assigned after ->hws has been > accessed: > > UBSAN: array-index-out-of-bounds in drivers/clk/bcm/clk-bcm2711-dvp.c:59:2 > index 0 is out of range for type 'struct clk_hw *[] __counted_by(num)' (aka 'struct clk_hw *[]') > > Move the ->num initialization to before the first access of ->hws, which > clears up the warning. > > Cc: stable@vger.kernel.org > Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") > Signed-off-by: Nathan Chancellor > --- Applied to clk-next _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel