From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332416; b=VLVc2b7mhSDyJoxJc5ZlA0GYkSSB7tcTy+uc+7C6KuTqu/Rz6E+AgoPGMSQjbQTjaHDb JIk807UAo9DS8fbuiPmmxQaFXKpxDgUr3r8u43UK4t9JLPwLA9B/8ENDNzNcFfGm22xt+ m/vXBAcTZo5LiwVL3ZfUThEMt2mKb5SCjpykoncroPZz1Iu1zZ3hPFCTJFEZJUxVYy61t xHqSptv/Bs6aJqad247xqHBjZa7Kcv1RAYecw+B3W7LHNIbTsX4jDBTm3s+OSNvJVavQC RBTMS/BVwV8hCzH0ECSph4ptpU+gYEC/bzVapksWB+WvLH2IGs1HW0mGvORZFnpUI0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332416; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9+IiU6TjTNrwMOcU8cgWv8aXZ5c32pbivKkNcbj6/gw=; b=dFSndwXfygBtD3FxzNHklTGpce+edEmmAmZ/sy1UFBWRLaCcQ67LMZyy+VNeMYnXYGQo AtRiQsw3Xz64SHiKqyDgJl/E0mh7+JPn453ulHnk2j3VUXklg/JQJYLfDRoFteQa1Yih2 Fg5WLIkD0xhSyHmDj8f+8lBPVHnPP7PktsP38WsuiThk9Sh7QOU8SGngRmp161BZueSAy J7diAYtuaEw73Fn5qkbTIlZP5JeIeCCzRsFMbZjQVMbf9BnlP0+Q1n5CoN+rLkrcmLh0I 8g3ygatzq8J8bc5j/wZ1H1yE+SMpt7AI7foVfWP6FSpPs5axS1u5RZJg+Ft/Um0+F2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Jf9DjUOw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68275606A322 for ; Thu, 3 Dec 2026 21:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Jf9DjUOw Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01131F000C2; Thu, 3 Dec 2026 21:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796332416; bh=9+IiU6TjTNrwMOcU8cgWv8aXZ5c32pbivKkNcbj6/gw=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Jf9DjUOwnbC7oIvc34k87K+J+S7YiucH/xNmC8D/GrN5OCcoZFkw5LRksZNm7N2ZY OdjqDvJSgCVqXrzhDBHAaG3z2Q7hWNpCDjH4cK+XqHmHF5bwqOYUopvA7sxOBVnxQ8 AKZoSON5DOglID+BtMaddV6USM2yMOe+rB/fFbBLOTJB0ELnpGX/mOXpTQvM7/yoky 60bMEBoT0TyO76QW6mc0XDGKd5Mj1EuP3kmiGSf1GHlBw266w0/dc+ipeTrsLCs00c msPYDyodDWuwKUGzVY8SVlWjwebtlwTHuFr5xHWjgditZ2tv4CwO7Qc+Oo1SpLjoBF /9X4k2d5kVMew== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 03/10] gpio: mvebu: Clear chained IRQ handlers on unbind Reply-To: sashiko-reviews@lists.linux.dev To: "Lee Jones" , linux-gpio@vger.kernel.org In-Reply-To: <20261203205606.3905705-4-lee@kernel.org> References: <20261203205606.3905705-1-lee@kernel.org> <20261203205606.3905705-4-lee@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 21:13:35 +0000 X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] gpio: mvebu: unsynchronized chained IRQ teardown on unbind -- commit 654c33aa50f3c81332c15236e0d1862887658524 Author: Lee Jones gpio: mvebu: Clear chained IRQ handlers on unbind This commit registers a devm cleanup action in mvebu_gpio_probe() to clear each bank's chained IRQ handler when the device is unbound. > diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c > index 8cb240a46a175..b9e1c4d02f579 100644 > --- a/drivers/gpio/gpio-mvebu.c > +++ b/drivers/gpio/gpio-mvebu.c > @@ -1182,6 +1182,17 @@ static void mvebu_gpio_remove_irq_domain(void *dat= a) > irq_domain_remove(domain); > } > =20 > +static void mvebu_gpio_remove_chained_handlers(void *data) > +{ > + struct mvebu_gpio_chip *mvchip =3D data; > + > + for (unsigned int i =3D 0; i < ARRAY_SIZE(mvchip->bank_irq); i++) { > + if (mvchip->bank_irq[i] > 0) > + irq_set_chained_handler_and_data(mvchip->bank_irq[i], > + NULL, NULL); > + } > +} > + > static int mvebu_gpio_probe(struct platform_device *pdev) > { > struct mvebu_gpio_chip *mvchip; [Severity: Medium] Can unbinding the device still use-after-free mvchip, its regmaps, and mvchip->domain if a GPIO bank interrupt is already running on another CPU? irq_set_chained_handler_and_data() clears handler_data, masks the IRQ, and installs handle_bad_irq under desc->lock, then returns without waiting for an in-flight chained handler. Chained flow handlers run in hardirq context without holding desc->lock or setting IRQD_IRQ_INPROGRESS: CPU0 CPU1 mvebu_gpio_irq_handler() mvchip =3D irq_desc_get_handler_data= () mvebu_gpio_remove_chained_handlers() irq_set_chained_handler_and_data() mvebu_gpio_remove_irq_domain() ... (devres frees regmaps, mvchip) regmap_read(mvchip->regs, ...) <-- use-after-free This also leaves the GPIO interrupt mask registers enabled. On parent controllers without irq_eoi, such as Armada XP's mpic_irq_chip, an in-flight handler's chained_irq_exit() calls chip->irq_unmask() after teardown masked the bank IRQ, leaving it unmasked with handle_bad_irq. Because chained handlers do not set IRQD_IRQ_INPROGRESS and mpic_irq_chip lacks irq_get_irqchip_state, synchronize_irq() alone is not enough. Mask the GPIO interrupts, detach the handlers, wait for in-flight hardirqs (e.g. synchronize_rcu()), and ensure parent IRQs stay masked before freeing. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203205606.3905= 705-1-lee@kernel.org?part=3D3