From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Boyd Date: Tue, 22 Aug 2023 14:00:34 -0700 Subject: [PATCH] clk: Annotate struct clk_hw_onecell_data with __counted_by In-Reply-To: <20230817203019.never.795-kees@kernel.org> References: <20230817203019.never.795-kees@kernel.org> Message-ID: List-Id: To: linux-aspeed@lists.ozlabs.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Quoting Kees Cook (2023-08-17 13:30:22) > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_data. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Joel Stanley > Cc: Andrew Jeffery > Cc: Taichi Sugaya > Cc: Takao Orito > Cc: Qin Jian > Cc: Andrew Lunn > Cc: Gregory Clement > Cc: Sebastian Hesselbarth > Cc: Andy Gross > Cc: Bjorn Andersson > Cc: Konrad Dybcio > Cc: Sergio Paracuellos > Cc: Matthias Brugger > Cc: AngeloGioacchino Del Regno > Cc: Maxime Ripard > Cc: Chen-Yu Tsai > Cc: Jernej Skrabec > Cc: David Airlie > Cc: Daniel Vetter > Cc: Samuel Holland > Cc: Vinod Koul > Cc: Kishon Vijay Abraham I > Cc: linux-clk at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: linux-aspeed at lists.ozlabs.org > Cc: linux-arm-msm at vger.kernel.org > Cc: linux-mediatek at lists.infradead.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-sunxi at lists.linux.dev > Cc: linux-phy at lists.infradead.org > Signed-off-by: Kees Cook > --- Applied to clk-next From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D83B2018C; Tue, 22 Aug 2023 21:00:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9C1C433C8; Tue, 22 Aug 2023 21:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692738036; bh=Bfl9Q+5PUYbGX93gC/p5dsy9+HHVDK69a8BX8HMEtCU=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=GZpOGvaIQjPh2lkGmj4jrgl7PGiUtpu6L07cneYELTEjIgB8Hz1gzNwk2c9ObPAmq viXdFFEbVNOD43Gz6sCjHQZxQg2e7OAsXHdD+UyK/NKk2j7zavpWtjgyY3YFxBAuUD C5fTdTtWEBm/Czz5ibqpn8wVDDdGM4w+3QQD9eLk02gSAZZ/ZASO+1gq+pRPVfL/g6 0CJ6lGLxQyjRE+GQwlQ81qbXHjZLqOlRNZzGVBv0zyniq/nrtBm6+rbslW53DAMctp K1pnfey+QNClhJ3zugG68htX/BGAUZW0g8Wva8QEjsr86rP7rP3X/BOzWOYRu6JmnN IIym9YlDIldXQ== Message-ID: Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20230817203019.never.795-kees@kernel.org> References: <20230817203019.never.795-kees@kernel.org> Subject: Re: [PATCH] clk: Annotate struct clk_hw_onecell_data with __counted_by From: Stephen Boyd Cc: Kees Cook , Joel Stanley , Andrew Jeffery , Taichi Sugaya , Takao Orito , Qin Jian , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Sergio Paracuellos , Matthias Brugger , AngeloGioacchino Del Regno , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , David Airlie , Daniel Vetter , Samuel Holland , Vinod Koul , Kishon Vijay Abraham I , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspe ed@lists.ozlabs.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-sunxi@lists.linux.dev, linux-phy@lists.infradead.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org To: Kees Cook , Michael Turquette Date: Tue, 22 Aug 2023 14:00:34 -0700 User-Agent: alot/0.10 Quoting Kees Cook (2023-08-17 13:30:22) > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). >=20 > As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_d= ata. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. >=20 > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/c= ounted_by.cocci >=20 > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Joel Stanley > Cc: Andrew Jeffery > Cc: Taichi Sugaya > Cc: Takao Orito > Cc: Qin Jian > Cc: Andrew Lunn > Cc: Gregory Clement > Cc: Sebastian Hesselbarth > Cc: Andy Gross > Cc: Bjorn Andersson > Cc: Konrad Dybcio > Cc: Sergio Paracuellos > Cc: Matthias Brugger > Cc: AngeloGioacchino Del Regno > Cc: Maxime Ripard > Cc: Chen-Yu Tsai > Cc: Jernej Skrabec > Cc: David Airlie > Cc: Daniel Vetter > Cc: Samuel Holland > Cc: Vinod Koul > Cc: Kishon Vijay Abraham I > Cc: linux-clk@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-aspeed@lists.ozlabs.org > Cc: linux-arm-msm@vger.kernel.org > Cc: linux-mediatek@lists.infradead.org > Cc: dri-devel@lists.freedesktop.org > Cc: linux-sunxi@lists.linux.dev > Cc: linux-phy@lists.infradead.org > Signed-off-by: Kees Cook > --- Applied to clk-next 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6771AEE49AF for ; Tue, 22 Aug 2023 21:00:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B060A10E2E9; Tue, 22 Aug 2023 21:00:40 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4508B10E2E9 for ; Tue, 22 Aug 2023 21:00:38 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7AE7D612C5; Tue, 22 Aug 2023 21:00:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9C1C433C8; Tue, 22 Aug 2023 21:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692738036; bh=Bfl9Q+5PUYbGX93gC/p5dsy9+HHVDK69a8BX8HMEtCU=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=GZpOGvaIQjPh2lkGmj4jrgl7PGiUtpu6L07cneYELTEjIgB8Hz1gzNwk2c9ObPAmq viXdFFEbVNOD43Gz6sCjHQZxQg2e7OAsXHdD+UyK/NKk2j7zavpWtjgyY3YFxBAuUD C5fTdTtWEBm/Czz5ibqpn8wVDDdGM4w+3QQD9eLk02gSAZZ/ZASO+1gq+pRPVfL/g6 0CJ6lGLxQyjRE+GQwlQ81qbXHjZLqOlRNZzGVBv0zyniq/nrtBm6+rbslW53DAMctp K1pnfey+QNClhJ3zugG68htX/BGAUZW0g8Wva8QEjsr86rP7rP3X/BOzWOYRu6JmnN IIym9YlDIldXQ== Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20230817203019.never.795-kees@kernel.org> References: <20230817203019.never.795-kees@kernel.org> Subject: Re: [PATCH] clk: Annotate struct clk_hw_onecell_data with __counted_by From: Stephen Boyd To: Kees Cook , Michael Turquette Date: Tue, 22 Aug 2023 14:00:34 -0700 User-Agent: alot/0.10 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , linux-aspeed@lists.ozlabs.org, Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-hardening@vger.kernel.org, linux-phy@lists.infradead.org, linux-clk@vger.kernel.org, Kishon Vijay Abraham I , Samuel Holland , Gregory Clement , Jernej Skrabec , Sergio Paracuellos , Chen-Yu Tsai , Andy Gross , Joel Stanley , linux-sunxi@lists.linux.dev, Sebastian Hesselbarth , Kees Cook , linux-arm-msm@vger.kernel.org, Maxime Ripard , Nathan Chancellor , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , Qin Jian , Andrew Jeffery , Bjorn Andersson , Nick Desaulniers , linux-kernel@vger.kernel.org, Konrad Dybcio , Taichi Sugaya , Vinod Koul , Takao Orito Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Quoting Kees Cook (2023-08-17 13:30:22) > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). >=20 > As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_d= ata. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. >=20 > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/c= ounted_by.cocci >=20 > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Joel Stanley > Cc: Andrew Jeffery > Cc: Taichi Sugaya > Cc: Takao Orito > Cc: Qin Jian > Cc: Andrew Lunn > Cc: Gregory Clement > Cc: Sebastian Hesselbarth > Cc: Andy Gross > Cc: Bjorn Andersson > Cc: Konrad Dybcio > Cc: Sergio Paracuellos > Cc: Matthias Brugger > Cc: AngeloGioacchino Del Regno > Cc: Maxime Ripard > Cc: Chen-Yu Tsai > Cc: Jernej Skrabec > Cc: David Airlie > Cc: Daniel Vetter > Cc: Samuel Holland > Cc: Vinod Koul > Cc: Kishon Vijay Abraham I > Cc: linux-clk@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-aspeed@lists.ozlabs.org > Cc: linux-arm-msm@vger.kernel.org > Cc: linux-mediatek@lists.infradead.org > Cc: dri-devel@lists.freedesktop.org > Cc: linux-sunxi@lists.linux.dev > Cc: linux-phy@lists.infradead.org > Signed-off-by: Kees Cook > --- Applied to clk-next