| Message ID | AS8P251MB00013E724A77A355668B6CCEC8B42@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-25627-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id C7F491C02D2 for <noreply@patchwork.local>; Sat, 5 Sep 2026 20:42:39 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=HOTMAIL.CO.UK; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-25627-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-25627-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 784AF2C192 for <noreply@patchwork.local>; Sat, 5 Sep 2026 18:40:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF50C37EFF1; Sat, 5 Sep 2026 18:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=HOTMAIL.CO.UK header.i=@HOTMAIL.CO.UK header.b="LfYRYWka" X-Original-To: linux-sunxi@lists.linux.dev Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazolkn19012008.outbound.protection.outlook.com [52.103.32.8]) (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 ACBB24EC661 for <linux-sunxi@lists.linux.dev>; Sat, 5 Sep 2026 18:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.103.32.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788633616; cv=fail; b=Y5orn8omwYFIqaP1zOM1/t9iEgA7NhHUAAYdbwbOSINNmXU8uTI9QzTY5cYba7sGpyW9iFYqYDDkbBO2qXrIw+XO3Rgxt7sr1N2l7ujpA0/ZZswB4W56a6p96AcbJU6iqPYEhTDcLR56bMOiKze7d1g79/SzY35qx3Yu25XSypg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788633616; c=relaxed/simple; bh=xa3gCqAQCSre/4B/7A8NetYCa6fiUCM9EYA5fXEAQAs=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=hZ7X2z9M4aG3qIabs3ffnKcSN0hHMOzrdXO1xXgybQxYtywKEw2CC6+Oi0QBHKRmBsiG8DAlGtbCycS1zmMNfZnTAgLdaDrdWog1YAK5SiDUyHjGnXeR5Jb/ATFs3TjL+FO49b/roqTg5WM0oqpSOctvqwzRPZ1QgDeY1SR5Gd8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.co.uk; spf=pass smtp.mailfrom=hotmail.co.uk; dkim=pass (2048-bit key) header.d=HOTMAIL.CO.UK header.i=@HOTMAIL.CO.UK header.b=LfYRYWka; arc=fail smtp.client-ip=52.103.32.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.co.uk ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O9j54hGDGTOWIEiGNENdEeDg0FJ7f7A4Rs0nqTnYhBqhhtDxT57loybeJoQPuvS19ENQov3gTtvT3rCRk/kCfc2F+VIfDhfR+BKC9y/Nf+thPK4oP1HHERw55YR92WK8eM50+QKRZ9sfoDOPdCD6mrBHWok+QJ9mamU0FLKNthS52CneVTptz8mB9aDQ6I7npO4IL7k++aW4H3/0611R8PkZtx2044rY1I81d+Ng7gk2YYFzMs9ikZXhqpd1iadaghSNtaTDrSKEPhEMXLkG4lTPmOiYwO3FW1Z4FFTsZMU1VC+zBO2YMkbSXCzorWhDBGlZqzqKDZrIUIO2ay5elA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aOC3xEnL0KZ2icP/yx/4hn7Iu+13puDSL4RJijeNQIg=; b=BD6ku67kLgEp7ejTMXjdSnqA6fm9XwbzVQdSf3SMhxJ4SMWYXkRis64wj1YuDWHeJVt5oeKLHQfhvqhE0a2YQhNEDbE8VDsCs1GoVzdoeVhSKc7+g0qMMMkcWk+bj1Kc/XNCmPC0kAvBVDaVEywO/i6S3L/tRDsO6xapvHIhDSieln29y/+hV5YeLOjdyABJUW7wHLDlE4QuvDeaNhCQemX9MylBEY7aUtL0Us+tZOrCtGXKr51gKvE20SKFQicX4C0iwc8zmQ8GyNluOjoL0hUNnhg0EiNtfwPFJcRYFnLNBWRDEjGIqmQXi+IHdGaYhjwnaL6EbUjjf1PHFEdeCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=HOTMAIL.CO.UK; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aOC3xEnL0KZ2icP/yx/4hn7Iu+13puDSL4RJijeNQIg=; b=LfYRYWkaoDUAlgolTc5XOGcoQ66zZZ53deMmGVbsfR5s8w/3gjlxgpdJoBc57+alnKTv4Lak9Kj7T5Qtx3K5SoivxHArRTG7zNE6GLb8kUTEdFI4a8SwgsHNu5efNRgyJnIU6vYNRuw1eYz0TfxDHOgYTTEgg8n0/CVbpd3Wx7FrcCyOZnKyOuWutXo5j+yQqj5SJNz0EOlqt1Agj8NYv98VUzIXet6FFCoWeePs0ZWUXWxb9NrjjNb+owcklQYa84nrPy+tDZCwZuuSPnipEcJQ5GzfbkE/YrVhDdzbYYf6Ku1/n0jTBco4wrlqWTedfW0+m4nzCzNal9drsAyHvQ== Received: from AS8P251MB0001.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:344::22) by GV2PPF5543EE396.EURP251.PROD.OUTLOOK.COM (2603:10a6:158:401::b58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Sat, 5 Sep 2026 18:40:11 +0000 Received: from AS8P251MB0001.EURP251.PROD.OUTLOOK.COM ([fe80::2952:d4d0:4ba:8352]) by AS8P251MB0001.EURP251.PROD.OUTLOOK.COM ([fe80::2952:d4d0:4ba:8352%6]) with mapi id 15.21.0382.012; Sat, 5 Sep 2026 18:40:11 +0000 From: Aamir Ahmed <elb12345@hotmail.co.uk> To: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai <wens@kernel.org>, linux-sunxi@lists.linux.dev, Kees Cook <kees@kernel.org>, linux-hardening@vger.kernel.org, Aamir Ahmed <elb12345@hotmail.co.uk>, stable@vger.kernel.org Subject: [PATCH] rtc: ac100: Assign .num before accessing .hws Date: Sat, 5 Sep 2026 19:38:08 +0100 Message-ID: <AS8P251MB00013E724A77A355668B6CCEC8B42@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM> X-Mailer: git-send-email 2.55.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO4P123CA0520.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:272::16) To AS8P251MB0001.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:344::22) X-Microsoft-Original-Message-ID: <20260905183808.4100-1-elb12345@hotmail.co.uk> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P251MB0001:EE_|GV2PPF5543EE396:EE_ X-MS-Office365-Filtering-Correlation-Id: a73dead2-7c5c-47fb-e416-08df0b7d1dd8 X-Microsoft-Antispam: BCL:0;ARA:14566002|8060799015|5062599005|19110799012|41001999006|5072599009|25010399006|4140399003|23021999003|37011999003|22121099003|25031999004|24021099003|39105399006|15080799012|26104999009|19061999003|3412199025|440099028|40105399003|2607281247196008|1710799026; X-Microsoft-Antispam-Message-Info: 0E2xGghawMFxBTyDvGksLd3vsrDtCrpbAe9+8PWLruViovfIfh022rhOogMdummx3z5bI214Cn9MuDNKZNcHSxVkYraD+JySR+N+JXUFOPVFMQOkmfA05pDz9azcQfoExLRC1VVvYWcPTPowayTBn85meCSLXa+YbmnG5V0V5HqQoguRn+eBsi0lTRicw4fh0iHB6cJbSUudKcmZf+BdJjLTO0Wc3o6BcU/wjsBFqz7dwx2bDadetOZ4WPLJ8ZpKghxRoqt3ks2ys0ezNOLwU9yYDX/SkRN6OsvBDvdSDPcrBpIs1szb7MIYA4xt/HASUQ/XHoXbPbuz0YclFwKa+f86swhDbvk7yq7M2KVjVISN59RPJJQVa3Oo/MtHtmWUawXPXWcpdPWDvFi4i9IiPdzVqi9TgApjd8jwTpuOU95FJs/Ej8Mi9tnGZc1fWrqAwHZOWGiXF6QnkpmK5huQKtpLkAU35eXI48qs4lrlW6SIkD3wtwPrH+ICp3uRNS6rv62l6KemLspMchJ1qUsh/z25dh4J6d2l5ow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T X-OriginatorOrg: sct-15-20-9412-3-msonline-outlook-fe3f5.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: a73dead2-7c5c-47fb-e416-08df0b7d1dd8 X-MS-Exchange-CrossTenant-AuthSource: AS8P251MB0001.EURP251.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2026 18:40:11.4815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PPF5543EE396 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-2.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; ARC_REJECT(1.00)[cv is fail on i=2]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; R_DKIM_ALLOW(0.00)[HOTMAIL.CO.UK:s=selector1]; FROM_HAS_DN(0.00)[]; PRECEDENCE_BULK(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo,hotmail.co.uk:email,HOTMAIL.CO.UK:dkim]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[elb12345@hotmail.co.uk,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-25627-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; DKIM_TRACE(0.00)[HOTMAIL.CO.UK:+]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; FREEMAIL_FROM(0.00)[hotmail.co.uk]; FREEMAIL_CC(0.00)[vger.kernel.org,kernel.org,lists.linux.dev,hotmail.co.uk]; DMARC_POLICY_ALLOW(0.00)[hotmail.co.uk,none]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: C7F491C02D2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
rtc: ac100: Assign .num before accessing .hws
|
|
Commit Message
Aamir Ahmed
Sept. 5, 2026, 6:38 p.m. UTC
Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with
__counted_by") annotated the hws member of 'struct clk_hw_onecell_data'
with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS)
about the number of elements in .hws[], so that it can warn when .hws[]
is accessed out of bounds. As noted in that change, the __counted_by
member must be initialized with the number of elements before the first
array access happens, otherwise there will be a warning from each access
prior to the initialization because the number of elements is zero.
This occurs in ac100_rtc_register_clks() due to .num being assigned only
after every clkout clock has been stored in .hws[]. With
CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC
15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report
during probe, and with CONFIG_UBSAN_TRAP the first store traps.
Initialize .num with AC100_CLKOUT_NUM, the number of elements .hws[] was
allocated with, right after the allocation. That is the value the loop
counter ends up at on the success path anyway, so the provider's
behaviour is unchanged.
Cc: stable@vger.kernel.org
Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Assisted-by: LLM
Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
---
Found while auditing the remaining clk_hw_onecell_data users that assign
.num only after touching .hws[], following the fixes already merged for
clk-s2mps11 (3e14c7207a97), exynos-clkout (cf33f0b7df13) and
clk-raspberrypi (6dc445c19050). The audit, the fix and this changelog
were drafted with an LLM assistant and reviewed by hand.
Compile-tested only (W=1, no warnings) on x86_64 with GCC 13.3, with
CONFIG_RTC_DRV_AC100=m forced on the make command line because the
driver has no COMPILE_TEST option. GCC 13.3 does not implement
__counted_by (CC_HAS_COUNTED_BY needs GCC 15.1+ or Clang 20.1+), so the
build only confirms that the change compiles; the sanitizer path was not
exercised. I do not have the hardware, so this is not runtime-tested and
no UBSAN report was captured.
Based on v7.3-rc1.
drivers/rtc/rtc-ac100.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
base-commit: 654ae5d73c05bd2943d65636ce6cd0aa46e62f18
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: Pre-existing issues: - [High] Missing cleanup of OF clock provider and fixed-rate clock on probe failure causes a Use-After-Free and resource leak. -- commit a37d5a060e39167e75415bce4b97e44f0383fe08 Author: Aamir Ahmed <elb12345@hotmail.co.uk> rtc: ac100: Assign .num before accessing .hws This commit assigns .num in struct clk_hw_onecell_data before accessing its .hws[] elements in ac100_rtc_register_clks(). This fixes a bounds sanitizer warning triggered by the __counted_by annotation introduced in a previous commit. > diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c > index bba7115ff3ad0..a2f465438fd05 100644 > --- a/drivers/rtc/rtc-ac100.c > +++ b/drivers/rtc/rtc-ac100.c [ ... ] > @@ -360,7 +362,6 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip) > chip->clk_data->hws[i] = &clk->hw; > } > > - chip->clk_data->num = i; > ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data); > if (ret) > goto err_unregister_rtc_32k; [Severity: High] This isn't a bug introduced by this patch, but does the lack of cleanup in ac100_rtc_probe() lead to a use-after-free and resource leak? In ac100_rtc_probe(), ac100_rtc_register_clks() manually registers a clock provider and a fixed-rate clock which are not devm-managed: drivers/rtc/rtc-ac100.c:ac100_rtc_probe() { ... ret = ac100_rtc_register_clks(chip); if (ret) return ret; return devm_rtc_register_device(chip->rtc); } If devm_rtc_register_device() fails, the probe function exits and devm cleans up chip->clk_data. However, since the clock provider is not unregistered on this error path, it remains active in the Common Clock Framework with a dangling pointer to the freed chip->clk_data. Can any subsequent attempt to query a clock via device tree traverse the provider list, dereference the freed pointer, and trigger a crash?
diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c index bba7115ff3a..a2f465438fd 100644 --- a/drivers/rtc/rtc-ac100.c +++ b/drivers/rtc/rtc-ac100.c @@ -317,6 +317,8 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip) if (!chip->clk_data) return -ENOMEM; + chip->clk_data->num = AC100_CLKOUT_NUM; + chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev, AC100_RTC_32K_NAME, NULL, 0, @@ -360,7 +362,6 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip) chip->clk_data->hws[i] = &clk->hw; } - chip->clk_data->num = i; ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data); if (ret) goto err_unregister_rtc_32k;