From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412636; b=Pn+rhsZ8d2yW/dQkVky8VOdgQTmI4rGs4DPYatvTUkVeh71fN3z8LZOED8aXS9b2rNxi BQCWQG47KsUWoHOAogpj9/6mIpTZKqm6b1w2CTxh+EJ22KQFkHLZInHmetjLq3meT1mVn iCHIEuxrqmd9GNnhCUjZWFqC6Uy0aFYk8WuiZOzRNG3aUCJR2EIDDyLm0+pYzAFvLmddg wJMp0DLkwRvL5CkDBTWFkZcNXXVwnSfbupKy1vU1eUIzPG9TSUrxIYRdMW+6Lp+X7QfeL 3iMSZQC9XFX3L8AIOKhzsUXOQHju/KEDc2dycy9fiCGOhfpqHfiI5M0IVRkEe8Ic9kg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412636; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=y9HVS8cICxJOrL9qpDb6jAdQIPipyklHVZ7kEcC11sYXrFeiGFTokRsgbp6Y6lXtiIx9 iVXewdb0mSJBi7f4BlPRhlPvIjFjHuqrQoxlaJgTD/AdxwQfGhG8lVpiBpWDZGrQOREie JlJw8CHZ2Y9D1Pq3fSAHCk4O4Ewy1fnlqrGAz+3PdbuHu32vQIkpoT6uZvm4w4aL742hM k/KjbJY3zTOVR/s4ZLFsi/FiXYITYw/x4yDuQhkUQM65rbJoJY0wLVwdH2bpABJ8MsLHA chpT2a4XxFZTo5Uk23QbLGpURrpswAOoYFX7xZjI/4W96qOLZNqvUuW0rGr3Pka2wtg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=hY85agk3; arc=none smtp.remote-ip=209.85.160.69 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FC7C606A322 for ; Fri, 4 Dec 2026 19:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FC7C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=hY85agk3 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-46dade0d7cdso1018705fac.1 for ; Fri, 04 Dec 2026 11:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412635; x=1797017435; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=hY85agk3C5YrJ46lwHah+oMmYW8KZmvmjuCRWS2m+1wcijXpmNrRqtI+wtkgou/jfF cxpbovr2w7gPgRbIacYfK0ki4QTFLrFPlYG1bzFe+LyY/+CHERmb9VZxXNpiQpqz3ung o6S8J0fU+1qUkDiZWQsifS0D4G5V2ejesL7Mz4ruHhOH9ZtVsawGpoMp3XJ2yvurq9tj DX33YH6JD6zoj7KFhZnanU5rEvfQVKTqs3VUzzeSPVKxRxApEL3M4Ob4MK0w8jjxtLa+ 0dKxLTgxPhifc501eaGmkPvsxl2NZWWGrUnsuRv32xFJI2+XsxTsntvocCFJmlZXeSp4 qQkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412635; x=1797017435; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=GvVaH3w2UTI+Q9/1ONLg0REBTBI3mMQ5FyAOtr6ETt2Q6ffNrzHLLfnuRJZqsbKchF mVHa/7e2behJRP7WWSsf5mr8cgdHq78QWeEAn9V/FkgToA6Cv/hrV+LMog2LrD1JOQ/0 N2jIok0aPorwDsuYTu41PNKn+GbkzyLcu+F4yWMPUVpQrjg9P1sYDLRtLKbH6fZoCS/K 5LKvrFI4PaigIH7BVWnIUB1NEYRikTMd3ByUHpTjSEK0bbJPhz8n8m/ZnyeVO8VskBJm twnFTPOdDtgIk+p8rCeaYB7DDUrlXTSrRz94JjlY2BI6TnrH5+w5x9A53PKtnZ+fZb67 8W5w== X-Forwarded-Encrypted: i=1; AL+hErETceu3Cq+G5thp9ZfiXsyDb7VVnZvEmDR6zf3rb0gYPFk+8jRlNKqizXfbyN7PXZCjy+mMjuG07LM=@vger.kernel.org X-Gm-Message-State: APuU4Z88/GUC5jeQyjH7khZ5fUOF6mMIEhCPeVob1A5RfNftO6CIMrdP b9IxsAN4jw0cKnGE2Y/cjzXgrY1R1PCgApH4xgmcEDzU+QTK2G1ouOFgSmvkdqbfzRgTqNFBL1o cwXXL+mGN1t63fO57DsFSEFrCGw== X-Received: from iofl6-n1.prod.google.com ([2002:a05:6602:8386:10b0:9e8:9d0f:5a50]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1691:b0:6df:d73a:1267 with SMTP id 006d021491bc7-71bf2087f58mr2553913eaf.40.1796412634909; Fri, 04 Dec 2026 11:30:34 -0800 (PST) Date: Fri, 4 Dec 2026 11:30:34 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-7-2b0e4e8d9ea6@cressey.dev> X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261203-clk-onecell-count-order-v1-0-2b0e4e8d9ea6@cressey.dev> <20261203-clk-onecell-count-order-v1-7-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 07/11] clk: clps711x: Assign .num before accessing .hws From: Justin Stitt To: Ben Cressey Cc: Junhui Liu , Manivannan Sadhasivam , Nobuhiro Iwamatsu , Michal Simek , Stephen Boyd , Brian Masney , Jerome Brunet , Paul Walmsley , Samuel Holland , Emil Renner Berthing , Hal Feng , Nathan Chancellor , Kees Cook , Nick Desaulniers , Bill Wendling , "Gustavo A. R. Silva" , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, Harry Austen , Changhuang Liang , stable@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Hi, On Thu, Dec 03, 2026 at 04:15:45PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but clps711x_clk_init_dt() > fills it before it sets num. The count is still zero with Clang 20 and > 21, where kzalloc_flex() does not set it, and on v6.6 to v6.19, which > use kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports > the accesses and CONFIG_UBSAN_TRAP makes the first one trap during boot. > > Set num right after the allocation. > > Found by an LLM-assisted check of __counted_by users. > > Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") > Cc: stable@vger.kernel.org > Signed-off-by: Ben Cressey > --- > drivers/clk/clk-clps711x.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c > index 27a57a9b3cb34..e2185b3daac99 100644 > --- a/drivers/clk/clk-clps711x.c > +++ b/drivers/clk/clk-clps711x.c > @@ -57,6 +57,7 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > CLPS711X_CLK_MAX); > BUG_ON(!clps711x_clk); > > + clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > spin_lock_init(&clps711x_clk->lock); > > /* Read PLL multiplier value and sanity check */ > @@ -139,7 +140,6 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > pr_err("clk %i: register failed with %ld\n", > tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp])); > > - clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > of_clk_add_hw_provider(np, of_clk_hw_onecell_get, > &clps711x_clk->clk_data); > } > > -- > 2.56.0 > Reviewed-by: Justin Stitt kjA Justin From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11489606A322 for ; Fri, 4 Dec 2026 19:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0KbISPli; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=dgcuHf20 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Unsubscribe-Post:List-Owner; bh=3P3AvH9sMz/reIspY1j+jvlF8NAJPCTUMkAd5QFT3zY=; b=0KbISPli6+es1P/vm3Z2ZFNbIy gmOMUbl8eWTn+rrmTx+pDl+nW8Ylpjd4lMbGN1zsujTu0anw01RM+vNpEdJfJy5XFoSbUKu0AC2wD BCYzYpQVHAypeSZRKMFwl9AlzEI0EkrMWmhiQOy+CZWnIg8LTrLui9qKy6xMYmLwYG5DrFsNZcZte difuzkPGPJerCxKpB9/1ld/MFc2qwFiEOcb9h1/JfbB6CoVI4Xi4dAn6xFDt0xpEEv9PjIJroizYh E2O6tbQWhu6SlPHDKU2thS1shfNSFkOUOzeeUIuZm7wPJc7VJXkHnsRcRwDFGZ8tYtg/9IwPxrpSz HmR8ebfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYzW-00000001IRr-3Hoq; Fri, 04 Dec 2026 19:30:49 +0000 Received: from mail-oo1-xc47.google.com ([2607:f8b0:4864:20::c47]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYzM-00000001INt-36PC for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 19:30:43 +0000 Received: by mail-oo1-xc47.google.com with SMTP id 006d021491bc7-702a9029845so1036645eaf.2 for ; Fri, 04 Dec 2026 11:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412635; x=1797017435; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=dgcuHf20kChC8kPcQqAzo24sa6cB9Pba4A+PWs9Xyvxqt83dsODeIZlbFaUYrlL1+N ochHdTp17FMGREIgJmH15xNG67zc5wJvjosfiTMnbuhZgvKSOi2Y+w1fEMB5z1tgJqW9 PkWm7mkwcgZ4KmlE2fP6JLdQUz7hYHXe2UHJMP498bTSBealH0zjkyN4YC3EuVdGQHo/ Dqu8/IyCPuoWBHuLWRaTJOwd/DdQt4XnRereK5sPoa3dsthZHs2ly/wtWovM8Ti64wzV EUMaSc2XYIbi7D061eQvlinEThLNkrqJ8+1ZElNHnAKMoTil8edUelhWzW+m7a0oP0R1 GVPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412635; x=1797017435; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=RYQi9KCIa4a92OGLs/KkrBn3mZTl+xSJZ36Lbvyip9LEHzzE6ch0ERC5BBimXMCa/1 cw/cTZmOfgM/a7mTEAWkTJapMR12mru6OfFiI7ZrrtRU5qGVT4J6XgumG0PxKRckgOvU krygf8L9Yr0WZmsbdYX3P4p0exCNl538ZE8LffQcWWV3wLAEmNb7iK07DcwD6N2V9z7C BGqtAwB6fEDI7SvsI1+ZrT6R0ixiC62OWWoe+byEmnjfuI5ZeeyTZiPt6+ABJJs5FiXW zBr7gpFQnvW7L4AujPc5S2KkMCndxDeTslGkxBMMpTC1jPO+0DAGaGr5295NKejp2LBG WY+Q== X-Forwarded-Encrypted: i=1; AL+hErFL7xU8+YawJx7JXeVaIDb+JOXOM7Z1DEz47FNcBSW48rfGB7pUl5UnLN8jOKXLlBqRy5OXYdtO3ngdnA==@lists.infradead.org X-Gm-Message-State: APuU4Z9mKRvz28GC08m+u9RJVOyTrUcBBEixu7CvTSJEPXmWVprWBoE4 UaH2Zn/vjPF2Z1fKraanSSxuBV3+dL02DGiDYo1GuI2Q3889N0NGVVlW276tNwm1Obf2iav0P33 JBmIFqWJvsY3xW6EdlWvXLDRQdg== X-Received: from iofl6-n1.prod.google.com ([2002:a05:6602:8386:10b0:9e8:9d0f:5a50]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1691:b0:6df:d73a:1267 with SMTP id 006d021491bc7-71bf2087f58mr2553913eaf.40.1796412634909; Fri, 04 Dec 2026 11:30:34 -0800 (PST) Date: Fri, 4 Dec 2026 11:30:34 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-7-2b0e4e8d9ea6@cressey.dev> X-Archived-By: Mime-Version: 1.0 References: <20261203-clk-onecell-count-order-v1-0-2b0e4e8d9ea6@cressey.dev> <20261203-clk-onecell-count-order-v1-7-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 07/11] clk: clps711x: Assign .num before accessing .hws From: Justin Stitt To: Ben Cressey Cc: Junhui Liu , Manivannan Sadhasivam , Nobuhiro Iwamatsu , Michal Simek , Stephen Boyd , Brian Masney , Jerome Brunet , Paul Walmsley , Samuel Holland , Emil Renner Berthing , Hal Feng , Nathan Chancellor , Kees Cook , Nick Desaulniers , Bill Wendling , "Gustavo A. R. Silva" , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, Harry Austen , Changhuang Liang , stable@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_113036_794528_80C552A3 X-CRM114-Status: GOOD ( 18.00 ) X-Spam-Score: -9.5 (---------) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi, On Thu, Dec 03, 2026 at 04:15:45PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but clps711x_clk_init_dt() > fills it before it sets num. The count is still zero with Clang 20 and > 21, where kzalloc_flex() does not set it, and on v6.6 to v6.19, which > use kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports > the accesses and CONFIG_UBSAN_TRAP makes the first one trap during boot. > > Set num right after the allocation. > > Found by an LLM-assisted check of __counted_by users. > > Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") > Cc: stable@vger.kernel.org > Signed-off-by: Ben Cressey > --- > drivers/clk/clk-clps711x.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c > index 27a57a9b3cb34..e2185b3daac99 100644 > --- a/drivers/clk/clk-clps711x.c > +++ b/drivers/clk/clk-clps711x.c > @@ -57,6 +57,7 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > CLPS711X_CLK_MAX); > BUG_ON(!clps711x_clk); > > + clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > spin_lock_init(&clps711x_clk->lock); > > /* Read PLL multiplier value and sanity check */ > @@ -139,7 +140,6 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > pr_err("clk %i: register failed with %ld\n", > tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp])); > > - clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > of_clk_add_hw_provider(np, of_clk_hw_onecell_get, > &clps711x_clk->clk_data); > } > > -- > 2.56.0 > Reviewed-by: Justin Stitt kjA Justin _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv