From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F342DC48BC4 for ; Thu, 15 Feb 2024 02:31:57 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=ZRbSjk+F; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TZzbc4JJyz3dV3 for ; Thu, 15 Feb 2024 13:31:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=ZRbSjk+F; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TZzZn58S4z3bwj for ; Thu, 15 Feb 2024 13:31:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1707964269; bh=mN7k05qDsCZMvJ231ko7Ex1DhgQgMDJKRw5c4Jz+Jno=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZRbSjk+F0dN7h56CW1VVMZbPdYMZNjqNRFpLazen7bRueZ0r5T1ywezmodVpyjVa9 d92F0UbPkk9cWKe/PUaolTj0uuHCqNcK/ovV+hA+9r8vgDHeXTd6hLN6wCeRtjDm12 wkrFjy7X7ibTf+qIS411Cy5ElqNoS0q5GnEN+y7jmi5FPb/ixivhx/JpCR66PfFpwA JP9jt3Lz0hSKEVJYKjPr8MT4mthYB057UdEkBZa4JxTJLbg6Uas//RbUT4CmRP2859 ZbXPQ2xV1m3X13wKW1QvIjjvoRUVCp+CRxl7+/GFzsANQTLT9gMRfrag8IblLb8+dG 7cgXHvEiWtt2Q== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4TZzZg5B7Nz4wxv; Thu, 15 Feb 2024 13:31:07 +1100 (AEDT) From: Michael Ellerman To: Shivaprasad G Bhat , iommu@lists.linux.dev, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2] powerpc/iommu: Fix the iommu group reference leak during platform domain attach In-Reply-To: <170793401503.7491.9431631474642074097.stgit@linux.ibm.com> References: <170793401503.7491.9431631474642074097.stgit@linux.ibm.com> Date: Thu, 15 Feb 2024 13:31:06 +1100 Message-ID: <875xyq791x.fsf@mail.lhotse> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: venkat88@linux.vnet.ibm.com, jroedel@suse.de, gbatra@linux.vnet.ibm.com, sbhat@linux.ibm.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, aneesh.kumar@kernel.org, jgg@ziepe.ca, tpearson@raptorengineering.com, npiggin@gmail.com, bgray@linux.ibm.com, naveen.n.rao@linux.ibm.com, vaibhav@linux.ibm.com, aik@amd.com Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Shivaprasad G Bhat writes: > The function spapr_tce_platform_iommu_attach_dev() is missing to call > iommu_group_put() when the domain is already set. This refcount leak > shows up with BUG_ON() during DLPAR remove operation as, > > KernelBug: Kernel bug in state 'None': kernel BUG at arch/powerpc/platforms/pseries/iommu.c:100! > Oops: Exception in kernel mode, sig: 5 [#1] > LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=8192 NUMA pSeries > > Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_016) hv:phyp pSeries > NIP: c0000000000ff4d4 LR: c0000000000ff4cc CTR: 0000000000000000 > REGS: c0000013aed5f840 TRAP: 0700 Tainted: G I (6.8.0-rc3-autotest-g99bd3cb0d12e) > MSR: 8000000000029033 CR: 44002402 XER: 20040000 > CFAR: c000000000a0d170 IRQMASK: 0 > GPR00: c0000000000ff4cc c0000013aed5fae0 c000000001512700 c0000013aa362138 > GPR04: 0000000000000000 0000000000000000 0000000000000000 0000000119c8afd0 > GPR08: 0000000000000000 c000001284442b00 0000000000000001 0000000000001003 > GPR12: 0000000300000000 c0000018ffff2f00 0000000000000000 0000000000000000 > GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR24: c0000013aed5fc40 0000000000000002 0000000000000000 c000000002757d90 > GPR28: c0000000000ff440 c000000002757cb8 c00000183799c1a0 c0000013aa362b00 > NIP [c0000000000ff4d4] iommu_reconfig_notifier+0x94/0x200 > LR [c0000000000ff4cc] iommu_reconfig_notifier+0x8c/0x200 > Call Trace: > [c0000013aed5fae0] [c0000000000ff4cc] iommu_reconfig_notifier+0x8c/0x200 (unreliable) > [c0000013aed5fb10] [c0000000001a27b0] notifier_call_chain+0xb8/0x19c > [c0000013aed5fb70] [c0000000001a2a78] blocking_notifier_call_chain+0x64/0x98 > [c0000013aed5fbb0] [c000000000c4a898] of_reconfig_notify+0x44/0xdc > [c0000013aed5fc20] [c000000000c4add4] of_detach_node+0x78/0xb0 > [c0000013aed5fc70] [c0000000000f96a8] ofdt_write.part.0+0x86c/0xbb8 > [c0000013aed5fce0] [c00000000069b4bc] proc_reg_write+0xf4/0x150 > [c0000013aed5fd10] [c0000000005bfeb4] vfs_write+0xf8/0x488 > [c0000013aed5fdc0] [c0000000005c0570] ksys_write+0x84/0x140 > [c0000013aed5fe10] [c000000000033358] system_call_exception+0x138/0x330 > [c0000013aed5fe50] [c00000000000d05c] system_call_vectored_common+0x15c/0x2ec > --- interrupt: 3000 at 0x20000433acb4 > > ---[ end trace 0000000000000000 ]--- > > The patch makes the iommu_group_get() call only when using it there by > avoiding the leak. > > Fixes: a8ca9fc9134c ("powerpc/iommu: Do not do platform domain attach atctions after probe") > Reported-by: Venkat Rao Bagalkote > Closes: https://lore.kernel.org/all/274e0d2b-b5cc-475e-94e6-8427e88e271d@linux.vnet.ibm.com > Signed-off-by: Shivaprasad G Bhat > --- > Changelog: > v1: https://lore.kernel.org/all/170784021983.6249.10039296655906636112.stgit@linux.ibm.com/ > - Minor refactor to call the iommu_group_get() only if required. > - Updated the title, description and signature(Closes/Reported-by). Sorry I already applied v1. If you send this as a patch on top of v1 with a new change log I can merge it as a cleanup/rework. cheers