From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412636; b=F4TsGX0TkRMR4nUMzOitJPvOec812/y3hnsj0SQVkeaIvxweDm5aPxnvdtlHVctW+lGg 1ycOF/5B1dqYUaZZDgopvwCFAqrgFKDLzOy91hyguzY/xSIcw0Rj/DE9P7638gJjwUHhp 6JYUHz49ueRnJWI99IUkM6m8lYkj4nYi5zseZZQf1Wy7rLuc8mArv6mAFJ4QoVGuS79L5 o4KjkwCmzF6yFTYzxrFyh4kBL2Ut+ilOEeOXacd/3WWZvpirZyjbsAwdqPftHxXuf2Gxb p4J0PSQdX03YS+Kj5dnOvqHDUwMNomy6GbQHWc5W4Jg0dvW11oN3M/EP+wrph9ICqwQ== 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=pt/+a0F4K8ByJfCG67x54UcTnyHxeF9yOWWsTdLvaK6RoRMEdl0hXaayey4l72g7dHT3 QTQkFw9eOq2C9rq228rKrID77C08ZZ95HgaC54s93KgPKh7+emV0h+2wSUlW9qxgIwjwK 5Mv1tm8ExZRZIQWHY+SLR0ZBChAcb3XHLeclhSJH4lQ/2nuMwpjW6bPrvnDVEIJgkT0AI KNH/B4tKMNl4Lu5Ngl+qQLP/94JyqrBw4QrO3TVEeWAXjOoKGvDZwlrEs7bKjbemxMcqj 1eG7N04ndqxfN2hCL8cbnJre/ksWq2hSXkvS3ymGngFwGDj1XM7NEYPcjOP54/06mvQ== 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.70 Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) (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 2662A606A32C for ; Fri, 4 Dec 2026 19:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2662A606A32C 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-f70.google.com with SMTP id 586e51a60fabf-4cf8e45c10fso1365207fac.3 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=Vv5rGhGTppM0SHfHyuo8DEcnTQrXqVOtTmZicMVsBe9Z+cnGbb42hspeveyzUNHDe9 Il4S6cuBZDpi42q6Z9OZ1EPW4OvF1XWvgiMrAzWAANpqEKImDObtRutxZHjLNIvClFP3 pxnGbbomeHn/K2ncC6t9cwISPrzjFoD/s219u4zj9qlFfSxm4RdG5BuUkWAb85WwzV47 wnAuPHcIomts70QhHK6tJ0SrqZi7rdziQkEVxdJ+ttY384FiHFjhZh1iq9KLoTmz1C3e ALuSi3XLVtGFy20mHuf6YL84lo6fFP8n5v630/VPpKkTfSWSUVDYR+tWO1+tVpZ+PtY6 3BnQ== X-Forwarded-Encrypted: i=1; AL+hErGguF0VfZ0LzDfxz5+e8Rj76KePuhZnBdDMzCpw5BzMlDNVGV7W2F9JzCgyMyxey6Bfs+TIkAZ4LmrtjAfwJUU=@vger.kernel.org X-Gm-Message-State: APuU4Z/4PxOWAdFDes+f197mAfj7CT8IDmObTTv+3qqeIw/mqT8M/ou/ VwuY5GlAyWhLLHpiwg81eVzvENVEX33AAj4Lu8arUOjHxMnxSKHQxpK2KTR71JyeL8VJ2sjxyCm kV8VDwHTCypnuTjy5cpCIlfXmCg== 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-hardening@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