From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412552; b=ZTVi2yByPQmUP6LHKBR7alPRKjBz0id1s0NzeH2bwhbXxqMpjUfFL479048ctTddDnAr MgUUAMaMzhdeuIkFWmntA7cNJM4StzeLHM9PG/zA7oGF4Zu5b4Lmo426t29r1xMPrBUWh fJXpdMpsCSnGOQEHt3afUaXVMNTNk6EB/oasIW4bY5tl5J37ed2By2+defUkVFnMX9TOj hli4XfoCBrFE859QUuvLVRSxOdddsAwLI9/lGe02EdykKG9VSzZFyBGBGZYn40wXz5xcG SQcEEwQ/3NJLA/Qbdx8zPKhmrNP5LZL2kBM+4le/DEskNyiMl3Sgwr08WfhXs4CtGwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412552; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=rDaAX0AK7GVmSD5PBUCJ19FeaRaOP2mEDJKzLSGXOlFtPtuH8CGSZ28pqLTzHtg1VCow flYsT53ncm3xyd2aIZqmuatdddoanVugOuA5KZ5T0CuXGIGfrb+q+O5L4h6It702+DxeZ aNkvAtqIFjVse0RQM/VClRt5mOQIbxsJGJY6CtQROfo6sPqFIUvxBSIZPmplYV01c8KhJ Kwm81LNqgBDZliW9JkOxap6n/udhJUqcBwDIy4xGO+g+biStjQ4zTfFqpmpNFAOc43FWM 2ZBqey06S5gflXaIUI0ce/7dm4uuCdhGeHuuwuUSQIcp/s1tG4mPDq6838K27coTRNw== 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=hzfTFEb4; arc=none smtp.remote-ip=209.85.210.69 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.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 02627606A322 for ; Fri, 4 Dec 2026 19:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02627606A322 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=hzfTFEb4 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-8638cec661bso964284a34.3 for ; Fri, 04 Dec 2026 11:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412551; x=1797017351; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=hzfTFEb4vbPxygHmihKGGAB5wZGdQVJMELwXndeNdeRLBVndC+gzFeHe+LP7i4/iKl Cx6L9Ghz2aEnjT+3Fe630wL/lQOxx6b1h8LxkvVu7YpFCGZYD4oeQ+LwfDhyfEQqPG+5 Q3ImFJASc72XoAx4p1/9Y1dI96xoY+3i6UzUNoA7I4pqCIRx379RgQxKiskRYzZXDhbm zI5bE5mPoJh7BU8AwBb0Br1+yE8ADaY/FYN68kz/Zg2KAd9AwjTdJhZfm+NBZ1JiS6A1 KxO1etZY6u8kXIyp8HTKa9CBfuOJ6JcMmjYIXk72CYzJQ0yRnafTWSQ/nP0CNRAnSlib UegA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412551; x=1797017351; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=IR6zbTExpqMjL292sQwlCf2LKhQgG7c9xW9f5TmCMhA/6f6Q0Kle6q8o1z12WquTlV 6kTjc0enAkcEH12ZVh415K3HLz1ySQaXgxzzN4Ya4N8L65o2HWXFsDtxLUaR6+TQSKF+ sMEWGkvgKPfEzoFDYtENKIpMR30dtA3z/QgFP7WcRSqnpLkSVxVKcmFhUmEFbIAfydJV Hoj26/LJ2t49WuknFGfwCcTEXJQEKZqYd8HoyiVDfdCvj2WDyotvh5cQEIYstTlvsiOT f9daiZ7vg+iUQGEGaBxmwyCvOGixWbDssILxlsullR4NDPdB7ycUr3lIKf9/bsqfOtbB M7qw== X-Forwarded-Encrypted: i=1; AL+hErGN+8hyXfJ2S2i6Erkz0sruHfikp9UriYYqJcGPeadHMGzGSadnmznbZBTrD1TNwT298c5XwmP25JMmITJfneQ=@vger.kernel.org X-Gm-Message-State: APuU4Z++ZBiMnChL3h6FC4OV0/5MipYdQANSaaUa14ckrPmRNxXOVOYM 56PlHl2JgptzJRLNwfH3r0TlFhdoHHDBLlgY5I5eXWvQ9IhqHieex8AXsaK8xpBSkpz8uNVDLAp M7NIZWJ6uzwTLqwxLVN4oL1/kWw== X-Received: from jabge8.prod.google.com ([2002:a05:6638:6808:b0:621:d390:8d01]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1692:b0:71b:7bd3:8a77 with SMTP id 006d021491bc7-71bf1ad52aemr2665572eaf.6.1796412550766; Fri, 04 Dec 2026 11:29:10 -0800 (PST) Date: Fri, 4 Dec 2026 11:29:10 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-5-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-5-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 05/11] clk: visconti: 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:43PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but visconti_init_clk() fills > it before it sets num. The count is still zero with Clang 20 and 21, > where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which > use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS > reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap > during probe. > > 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/visconti/clkc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/visconti/clkc.c b/drivers/clk/visconti/clkc.c > index a75163b69751e..f8bb93d7027bc 100644 > --- a/drivers/clk/visconti/clkc.c > +++ b/drivers/clk/visconti/clkc.c > @@ -195,9 +195,9 @@ struct visconti_clk_provider *visconti_init_clk(struct device *dev, > if (!ctx) > return ERR_PTR(-ENOMEM); > > + ctx->clk_data.num = nr_clks; > for (i = 0; i < nr_clks; ++i) > ctx->clk_data.hws[i] = ERR_PTR(-ENOENT); > - ctx->clk_data.num = nr_clks; > > ctx->dev = dev; > ctx->regmap = regmap; > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin