[{"id":3680048,"web_url":"http://patchwork.ozlabs.org/comment/3680048/","msgid":"<20260421200609.GE1684602@rocinante>","list_archive_url":null,"date":"2026-04-21T20:06:09","subject":"Re: [PATCH v5 22/23] PCI/sysfs: Convert legacy I/O and memory\n attributes to static definitions","submitter":{"id":86709,"url":"http://patchwork.ozlabs.org/api/people/86709/","name":"Krzysztof Wilczyński","email":"kwilczynski@kernel.org"},"content":"Hello,\n\n> Currently, legacy_io and legacy_mem are dynamically allocated and\n> created by pci_create_legacy_files(), with pci_adjust_legacy_attr()\n> updating the attributes at runtime on Alpha to rename them and shift\n> the size for sparse addressing.\n> \n> Convert to four static const attributes (legacy_io, legacy_io_sparse,\n> legacy_mem, legacy_mem_sparse) with is_bin_visible() callbacks that\n> use pci_legacy_has_sparse() to select the appropriate variant per bus.\n> The sizes are compile-time constants and .size is set directly on\n> each attribute.\n> \n> Register the groups in pcibus_groups[] under a HAVE_PCI_LEGACY guard\n> so the driver model handles creation and removal automatically.\n> \n> Stub out pci_create_legacy_files() and pci_remove_legacy_files() as\n> the dynamic creation is no longer needed.  Remove the __weak\n> pci_adjust_legacy_attr(), Alpha's override, and its declaration from\n> both Alpha and PowerPC asm/pci.h headers.\n\nThere is feedback from Sashiko about this:\n\n  https://sashiko.dev/#/patchset/20260416180107.777065-1-kwilczynski%40kernel.org?part=22\n\nThis is a pre-existing issue that is does trip KASAN:\n\n  - Read successful; larger buffer.\n\n    root@kvm:~# dd if=/dev/zero of=/sys/class/pci_bus/0000:00/legacy_io bs=4 count=1 seek=32\n    1+0 records in\n    1+0 records out\n    4 bytes (4B) copied, 0.004042 seconds, 989B/s\n\n  - Splat; smaller buffer.\n\n    root@kvm:~# dd if=/dev/zero of=/sys/class/pci_bus/0000:00/legacy_io bs=1 count=1 seek=128\n    [  138.516163] ==================================================================\n    [  138.516843] BUG: KASAN: slab-out-of-bounds in pci_write_legacy_io+0x90/0xc8\n    [  138.517311] Read of size 4 at addr c29697b0 by task dd/37\n    [  138.517685] \n    [  138.518188] CPU: 0 UID: 0 PID: 37 Comm: dd Not tainted 7.0.0-rc1-g973e040579d6 #1 PREEMPTLAZY \n    [  138.518578] Hardware name: PowerMac3,1 7400 0xc0209 PowerMac\n    [  138.519019] Call Trace:\n    [  138.519165] [c2b8bbd0] [c12deee4] dump_stack_lvl+0x50/0x78 (unreliable)\n    [  138.519632] [c2b8bbf0] [c03f67e4] print_report+0x14c/0x514\n    [  138.519968] [c2b8bc50] [c03f646c] kasan_report+0x104/0x1d0\n    [  138.520288] [c2b8bcd0] [c0925e94] pci_write_legacy_io+0x90/0xc8\n    [  138.520624] [c2b8bcf0] [c0626cb4] kernfs_fop_write_iter+0x484/0x6cc\n    [  138.521003] [c2b8bd30] [c0419d1c] vfs_write+0x5fc/0x12f4\n    [  138.521299] [c2b8be60] [c041aeac] ksys_write+0x120/0x244\n    [  138.521605] [c2b8bf00] [c001d218] system_call_exception+0x14c/0x304\n    [  138.521976] [c2b8bf30] [c002b1bc] ret_from_syscall+0x0/0x2c\n    [  138.522317] ---- interrupt: c00 at 0x100a59f4\n    [  138.522695] NIP:  100a59f4 LR: 101005e4 CTR: b7bf44a0\n    [  138.523013] REGS: c2b8bf40 TRAP: 0c00   Not tainted  (7.0.0-rc1-g973e040579d6)\n    [  138.523413] MSR:  0000d932 <EE,PR,ME,IR,DR,RI>  CR: 28004462  XER: 00000000\n    [  138.524028] \n    [  138.524028] GPR00: 00000004 bfbff210 1027d520 00000001 102795a0 00000001 10277237 100a4ac4 \n    [  138.524028] GPR08: 0000d932 00000002 00000000 bfbff2c0 b7bf0000 102790b2 10230000 10226faa \n    [  138.524028] GPR16: 10237d81 00000000 00000000 102795a0 102795a0 00000000 1027721f 00000001 \n    [  138.524028] GPR24: 00000001 00000000 10271500 10270000 00000000 00000001 102795a0 00000001 \n    [  138.526014] NIP [100a59f4] 0x100a59f4\n    [  138.526264] LR [101005e4] 0x101005e4\n    [  138.526500] ---- interrupt: c00\n    [  138.526740] \n    [  138.526913] Allocated by task 37 on cpu 0 at 138.516066s:\n    [  138.527334]  kasan_save_track+0x3c/0x90\n    [  138.527572]  __kasan_kmalloc+0xb8/0xec\n    [  138.527816]  kernfs_fop_write_iter+0x55c/0x6cc\n    [  138.528076]  vfs_write+0x5fc/0x12f4\n    [  138.528269]  ksys_write+0x120/0x244\n    [  138.528472]  system_call_exception+0x14c/0x304\n    [  138.528688]  ret_from_syscall+0x0/0x2c\n    [  138.528950] \n    [  138.529108] The buggy address belongs to the object at c29697b0\n    [  138.529108]  which belongs to the cache kmalloc-8 of size 8\n    [  138.529673] The buggy address is located 0 bytes inside of\n    [  138.529673]  allocated 2-byte region [c29697b0, c29697b2)\n    [  138.530173] \n    [  138.530318] The buggy address belongs to the physical page:\n    [  138.531001] page: refcount:0 mapcount:0 mapping:00000000 index:0x0 pfn:0x2969\n    [  138.531454] flags: 0x0(zone=0)\n    [  138.532076] page_type: f5(slab)\n    [  138.532520] raw: 00000000 c1c01300 00000122 00000000 00000000 005500aa f5000000 00000000\n    [  138.533046] page dumped because: kasan: bad access detected\n    [  138.533372] \n    [  138.533496] Memory state around the buggy address:\n    [  138.533955]  c2969680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n    [  138.534328]  c2969700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n    [  138.534693] >c2969780: fc fc fc fc fc fc 02 fc fc fc fc fc fa fc fc fc\n    [  138.535066]                              ^\n    [  138.535358]  c2969800: fc fc fa fc fc fc fc fc fa fc fc fc fc fc 04 fc\n    [  138.535661]  c2969880: fc fc fc fc 00 fc fc fc fc fc fa fc fc fc fc fc\n    [  138.536058] ==================================================================\n    [  138.537335] Disabling lock debugging due to kernel taint\n    1+0 records in\n    1+0 records out\n    1 bytes (1B) copied, 0.023071 seconds, 43B/s\n\nSomething to fix as a follow-up.\n\nThank you!\n\n\tKrzysztof","headers":{"Return-Path":"\n <linux-pci+bounces-52882-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=PLk8TvvJ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52882-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"PLk8TvvJ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0YSb6q39z1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:13:03 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 93DDA310840B\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 20:06:12 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A543E3DCDB1;\n\tTue, 21 Apr 2026 20:06:11 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 829D13451C1;\n\tTue, 21 Apr 2026 20:06:11 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id AC9ACC2BCB0;\n\tTue, 21 Apr 2026 20:06:10 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776801971; cv=none;\n b=MVn50YXXrmgLa5z6wT4lh13hrGrVbvbQwkaE0V27qBCm/o2KkFNshwurx9+o2sMxVsEQzBlgYPcGQ74x3Rt5R94vSf0P/Wb4vpyRwh7PLqoJdkVmMqq4oJSwFQUEDwOvvkoRkxLxU7rbbJVqyPX19MkXNc4MeRV9+CtAKHJqjWQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776801971; c=relaxed/simple;\n\tbh=zLaqEY2AdfsU2z/D1pNc/O8p+28fE6XTfonBYfspxZc=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=FDMPyzdVq17Yq4OfhOUAgINLVMcga5rvVK+LmtelFLo3nEy3W32BhhMO2mzq4aSlES+Ggw1+bfc/wHHAOWVr2qOS3Siz/IanZJOcqXdU/g5ldmD6G7apVmaX0P8Bf4QUNh1o3ZAXKx+8/hU3JKrMUEtNcF/d32/wTmfP31xV6+U=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=PLk8TvvJ; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776801971;\n\tbh=zLaqEY2AdfsU2z/D1pNc/O8p+28fE6XTfonBYfspxZc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PLk8TvvJWIBLYMgP5fE2xmhBa2sDysetrsKMet0ZyBqA4TLBhTuhOrlV6iENIIWdR\n\t 9MV2DnzdojJcU3BaEzpZCq2nUisl1jhVxlquirkUp8NXpn/65Tey1NbkfAf0MoQRcv\n\t BpBJ4xsWX8UfXeTe08QMZri30FLYvVkHL44G4R3Hm2kTuyCO6FGLT0kmyUuMmo9qzC\n\t eHkN1fzraxOPfgFp/hQv5mF0ZAen36o18ZcP+xAqjQw9i1L1JMGfMochPPfqEaOKtP\n\t Z4t34hSHUtGQudYD+6ZGVOL5oHNDy5g84MtN1dY3ENmO/ZjzYdaXdh/GgRcBd6KaOs\n\t fKtSFqf6yTcTA==","Date":"Wed, 22 Apr 2026 05:06:09 +0900","From":"Krzysztof =?utf-8?q?Wilczy=C5=84ski?= <kwilczynski@kernel.org>","To":"Bjorn Helgaas <bhelgaas@google.com>","Cc":"Bjorn Helgaas <helgaas@kernel.org>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>,\n Magnus Lindholm <linmag7@gmail.com>, Matt Turner <mattst88@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Christophe Leroy <chleroy@kernel.org>,\n Madhavan Srinivasan <maddy@linux.ibm.com>,\n Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>,\n Dexuan Cui <decui@microsoft.com>,\n Krzysztof =?utf-8?q?Ha=C5=82asa?= <khalasa@piap.pl>,\n Lukas Wunner <lukas@wunner.de>, Oliver O'Halloran <oohall@gmail.com>,\n Saurabh Singh Sengar <ssengar@microsoft.com>,\n Shuan He <heshuan@bytedance.com>, Srivatsa Bhat <srivatsabhat@microsoft.com>,\n Ilpo =?utf-8?b?SsOkcnZpbmVu?= <ilpo.jarvinen@linux.intel.com>,\n linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org,\n linuxppc-dev@lists.ozlabs.org","Subject":"Re: [PATCH v5 22/23] PCI/sysfs: Convert legacy I/O and memory\n attributes to static definitions","Message-ID":"<20260421200609.GE1684602@rocinante>","References":"<20260416180107.777065-1-kwilczynski@kernel.org>\n <20260416180107.777065-23-kwilczynski@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260416180107.777065-23-kwilczynski@kernel.org>"}}]