From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412590; b=BmuvbaF0WzBK6r5nmY6dJ8KbH7hcVyGANRpC5ypTf8hJykAfZkOfsmmBfAzjg3V3+JR1 YnNbOB/q0aWyrtXFRlEqTrSI72wuBD2viUPMaCouCOMHhmagWK/1rYL+ALKKiZ9fhI0JM it9Hf7+fQynWIMR6dtJyEu058lPDt42vHNFDSAATF32I3wTPmBwkMmtSSk8qt+a9Ab8UO 9u/+4ANW9j4PDHCVVB5IFatDY4rdvd6+6N+2nRs3+1gQE0biMPl2re438l0xH0p6ZcG/u LLheuNlUXN/iOSqD7CH7TUsUUzsnvEv4BmtUfxHb+Y83HHV400+yfcXK2kwcUJ+TQdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412590; 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=M8REf+L1LmtLVoGbDnRKWfw/LSiyhCp271Nqb5eTRuo=; b=bXyTMQzLJZQ4ub0hqA+aHD5h0XDYCR+4nirI5bHNBBtu5b/hnWjlCC8zTAaHWaVS0EA9 WBog6adxvoVlQFGNQM2HzujT3YvCGlBvjdxL8pNz5EonSeXci7y/5KHYWZXHFNi4/++XW oE5O39/kh2AEbdvdO51gDHwTf7Ns8D5KkKPFMYSNjuuHguhv80dyZ1q5xIzrmcePHjeBn M5+FZ90hsa5HrK57SL7qYbcz9IJw1loAHecvsCcqBe+9Fr3u8v7+VWFfs8E/RN9pV+ZJO giWMM7Vzcbg2z1GlOzP48z30+8PYxAeH5nvJFCa1ztwtgdZo8ru8bZv4NZt/T/2kEwA== 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=VbHVEuNz; arc=none smtp.remote-ip=209.85.167.197 Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (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 2C94B606A32C for ; Fri, 4 Dec 2026 19:29:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C94B606A32C 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=VbHVEuNz Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-4b2d1eb484aso1393226b6e.2 for ; Fri, 04 Dec 2026 11:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412588; x=1797017388; 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=M8REf+L1LmtLVoGbDnRKWfw/LSiyhCp271Nqb5eTRuo=; b=VbHVEuNzJ6hAcpYvcCFNw4KpkPaw+FntiqVVW5SbXorUkNj2NN9qT9ekYZB0rqTJEo N6ccQwqVH5qZvLqyTpg4ZrwK0nSe6OHGmpcBk3j0z44r5VvxJcXYQxTIpvgnQvF3LxK6 7sAytlFD8CEp+lzXb/m4ZUhg7fHoxaa6NbRwsTKQK2a63+x7DZUe0sOELIlXji/blzbQ /fvxT7WvDcUtcyO4jHV+EeD2gdCsvsjAOiwNYnwmJPxFU5vP8M/db9XHjBbXX2Gm2NGV Xz9cIV1jchbSsrDL/rwXDZcb8GsFCQ8voGeWvuZnqPGKopqc7txUINWdskxZjo9DMrxb ppPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412588; x=1797017388; 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=M8REf+L1LmtLVoGbDnRKWfw/LSiyhCp271Nqb5eTRuo=; b=L37BAnlJbPEZZAtS4b1pKLA9WxynehJJsAK3AzCtN5AYOICwxnB5fOA6bcFKpQVAAm PfIDmRc6YT/S5mO+vzIf5/hMvZlT/ubqiWssU8BdgtEChFUkDHTGkAADCcXAwmHx7Hyj lkhgVslnlqF2x/7zz7Bf6Z4P+hq6nsGg9EYtokGUoyYqS6AOIsBN5GdqoDN5HWVlqHvm yfcN9RFb0xK73TFIZY/DihhvxYUIHoTFEIAMy5DgSZ4etxNHSUDEpmxIq8TKxX5mfiIQ PA4DWl8vSm/Pl39Lzbf6i2Uear7YBbYeoqLAl6HaG9OmbXm/zjN1Va49J6fIx4gcvWzV 4XkA== X-Forwarded-Encrypted: i=1; AL+hErFplJKu51L+Z22pRbqS+d9VfNvMhpsHYXRqRt4EUS6yexpaa8asAltpHTa4yxGRrK3RH24IBACHtvAWRmo07tQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9P1MjYDi9xC55HKX1aBrMuuLVvqNr03iOnqGt7rYSV8ldVJcQh z55Jh8ZttbBoTgnSbF1LQLpKgqJZi3RAyBKoxf5yWXrbyzNUuJeAAWj7eVgq4gMq9bFObb0L9xr TIe+kpNLbb412TKdw2qAFT7VYiw== X-Received: from oatk25-n1.prod.google.com ([2002:a05:687c:4399:10b0:4ad:6687:8fcc]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:14c6:b0:4d6:9153:2965 with SMTP id 5614622812f47-57f208b1526mr3399730b6e.54.1796412587956; Fri, 04 Dec 2026 11:29:47 -0800 (PST) Date: Fri, 4 Dec 2026 11:29:47 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-6-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-6-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 06/11] clk: clocking-wizard: 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:44PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but > clk_wzrd_register_output_clocks() fills it before clk_wzrd_probe() sets > num. The count is still zero with Clang 20 and 21, where > devm_kzalloc_flex() does not set it, and on v6.13 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. Nodes with xlnx,static-config do not reach this code. > > Set num right after the allocation. > > Found by an LLM-assisted check of __counted_by users. > > Fixes: bb487924b161 ("clk: clocking-wizard: use newer clk_hw API") > Cc: stable@vger.kernel.org > Signed-off-by: Ben Cressey > --- > drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > index 9f8830b40122a..d1e9b11da2011 100644 > --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > @@ -1302,6 +1302,7 @@ static int clk_wzrd_probe(struct platform_device *pdev) > nr_outputs); > if (!clk_wzrd) > return -ENOMEM; > + clk_wzrd->clk_data.num = nr_outputs; > platform_set_drvdata(pdev, clk_wzrd); > > clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0); > @@ -1337,7 +1338,6 @@ static int clk_wzrd_probe(struct platform_device *pdev) > if (ret) > return ret; > > - clk_wzrd->clk_data.num = nr_outputs; > ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get, > &clk_wzrd->clk_data); > if (ret) { > > -- > 2.56.0 > Reviewed-by: Justin Stitt 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 04465606A32C for ; Fri, 4 Dec 2026 19:30:29 +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=zcAmZ0mR; 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=K0ikIKe+ 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=R6tdW5DsMo4zEc/j191ttXJ2kKmDDrO9PzoidfjOth8=; b=zcAmZ0mRdqOpl+IyYVH6KFHVZN xgsiGK8GNzjBJHJ/P+o3Glj1RwnDP0WqHm181ZVPtM1OJO8ZK6uQpYA7N5cj6sCeduzmw4BqTPRWP YZI8bLcuoFTd3iQh1OKfbYyB6UoGzRSAy0YfJ99TpZ1vbGP2xYyYmBJOWAuBqo/mIncr8a5VWmScV bjEJISD23pEeg0QzlAEspSJBay1r1Kg9fqYdr1/u+7QOyVj8aO0lNvTIyXK41AcQGdtW7DFqjBrUe GUDCCAaFZGsWAflxITPOECPwzMgNkpkOCYg3lpfkyfI59mW+3zlZRMDAGwmTN9AOK7z73QJeqL2X+ muSCg8Sg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYyk-00000001IEf-2G6q; Fri, 04 Dec 2026 19:29:58 +0000 Received: from mail-oi1-x246.google.com ([2607:f8b0:4864:20::246]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYyc-00000001IBH-16sB for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 19:29:57 +0000 Received: by mail-oi1-x246.google.com with SMTP id 5614622812f47-4a41f46d629so1762839b6e.3 for ; Fri, 04 Dec 2026 11:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412588; x=1797017388; 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=M8REf+L1LmtLVoGbDnRKWfw/LSiyhCp271Nqb5eTRuo=; b=K0ikIKe+K8WcB4/lMyV/DH1jHAclXzZzRYRe1h1ZmLrF4o2iVZvKPR6MRzOtqffeUe fjgx8Pqc6X7foVYIANe4IJgG1sBPWG2/fzMWzU/SzyPyYPqzJhtOdGU3YyGKBwSZHr/V 2ZST7E5zCXaE4h08mXclLCm8jWucuV4xy6NBmb44IWbpjxUQ/0HL/QxnlYOgBKuLD3p5 KKAGhDNflI8l18pK1ffbhkxvodGE7WxYgSTQWbw6ZoUp0l0IyLwAksK0ctgypv1H5o0l jNjnOkOis503DJ/t+EI9C/Zyvbt7zHWkZoA/UJfVPt2FDBQmAN0SPYiHC2df2Nu3/FQ8 a1zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412588; x=1797017388; 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=M8REf+L1LmtLVoGbDnRKWfw/LSiyhCp271Nqb5eTRuo=; b=laJ1xSgZWSeGOC+JPSOQehwZh1E7y1OZwCt55BBD6s8ZeDFn7zi2QBWdqzzSmok4/I oB7RDZugrqPBIxYN+48USNgVy8TAZY4ZfM/+7nFyW1Lx0MEMONLd6tJNfOKwan47ny54 bTfVfYW5SRYkWYEvzDiaRzBZfjxeClWpCnTz23e0yCpWQil64LzhZfekPjhuGZaVJiuD jzxo827YOk848f/hsy/XH4vm0BxUBgWD2aGI0Jwvn0G7Faf4hX023fS7xk4hV4ulr5Dc 2M0Alel7Axg/dLewM+4rXv39H8YJuRA8xwvvqJCV3NYVIoztN3iW2/jeYMeQMpLWgR/D 3MOg== X-Forwarded-Encrypted: i=1; AL+hErFBPfBGYVLIe8LrHmPhYKpmkHwtT2QgMFLDBI2i+LLtxQH/uBGD14KcQUeas3M/2Hlu8wLC5Di1O8fpQw==@lists.infradead.org X-Gm-Message-State: APuU4Z+g64fr2KU6e4KBCm4t195UkGuzuBYetTniIjzPxivZ9i5QDiRy qLl9BKc3rriV0SOk6RrWd+pFw/BAVuA+T30hxnEsFLrcAU5s3c2a9cNMVMWpJOLiZeL5LDJpJ7K /BnwUcyXfYLlB+4R7EcAzfrsvyg== X-Received: from oatk25-n1.prod.google.com ([2002:a05:687c:4399:10b0:4ad:6687:8fcc]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:14c6:b0:4d6:9153:2965 with SMTP id 5614622812f47-57f208b1526mr3399730b6e.54.1796412587956; Fri, 04 Dec 2026 11:29:47 -0800 (PST) Date: Fri, 4 Dec 2026 11:29:47 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-6-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-6-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 06/11] clk: clocking-wizard: 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_112950_622828_E812390A X-CRM114-Status: GOOD ( 19.35 ) 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:44PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but > clk_wzrd_register_output_clocks() fills it before clk_wzrd_probe() sets > num. The count is still zero with Clang 20 and 21, where > devm_kzalloc_flex() does not set it, and on v6.13 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. Nodes with xlnx,static-config do not reach this code. > > Set num right after the allocation. > > Found by an LLM-assisted check of __counted_by users. > > Fixes: bb487924b161 ("clk: clocking-wizard: use newer clk_hw API") > Cc: stable@vger.kernel.org > Signed-off-by: Ben Cressey > --- > drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > index 9f8830b40122a..d1e9b11da2011 100644 > --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c > @@ -1302,6 +1302,7 @@ static int clk_wzrd_probe(struct platform_device *pdev) > nr_outputs); > if (!clk_wzrd) > return -ENOMEM; > + clk_wzrd->clk_data.num = nr_outputs; > platform_set_drvdata(pdev, clk_wzrd); > > clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0); > @@ -1337,7 +1338,6 @@ static int clk_wzrd_probe(struct platform_device *pdev) > if (ret) > return ret; > > - clk_wzrd->clk_data.num = nr_outputs; > ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get, > &clk_wzrd->clk_data); > if (ret) { > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv