From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EC9422D5940; Tue, 17 Mar 2026 17:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773767864; cv=none; b=Wf4i4hyCKB6e8NZRkp5qJTpz+s2iec8r7D/8IQj71Fawe91VyEBH+sPxyO6NEizBXHrjNE99X1jdC0k81hMoypyjRey7DU5y4jNFx8ZMRWzFdk/mXZZpTIbEGgvNzcZgEXO95+y49wH6iSUPaRDiounFqpVjKBCT2s5H0rpreHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773767864; c=relaxed/simple; bh=LQTaURo6SEdp7Dj8QI4CbwfqaDh/h66cT3FEqm7Ciko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p6/I/PbX4rwUYWqS2z26jiQDRHFOkuq3xs4mr+emgiaM4/+CcOYZBOE4EHbw8LovIwciHde2G8wrngZTkmSA1Sw/e43Z3sSkhaGeRzEjIX3bw9dJjbBLdNX8Q+gDma5k/SJLJX47vHYS72eGcbAneeqzhIfbzuxPkwSXCixcLNQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fC5w5OU3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fC5w5OU3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 292F4C4CEF7; Tue, 17 Mar 2026 17:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773767863; bh=LQTaURo6SEdp7Dj8QI4CbwfqaDh/h66cT3FEqm7Ciko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fC5w5OU3XEqcpDHPNr7OxlCf83qmbeViyage8Mf1IjJXEVwg2Q1z/xtIBXwMTk3mS g1szixRzn8etJOkxLRMSNF/91G26/1WDjLUy8Qr9Ct+zVavmcxCNDKTEP3XM5fYaEZ yCSMZK9D4JJW3JkN1b4rUwQWidkUOTTjPLlDNfu0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Alan Stern , Fan Wu Subject: [PATCH 6.18 142/333] usb: renesas_usbhs: fix use-after-free in ISR during device removal Date: Tue, 17 Mar 2026 17:32:51 +0100 Message-ID: <20260317163004.626611734@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260317162959.345812316@linuxfoundation.org> References: <20260317162959.345812316@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fan Wu commit 3cbc242b88c607f55da3d0d0d336b49bf1e20412 upstream. In usbhs_remove(), the driver frees resources (including the pipe array) while the interrupt handler (usbhs_interrupt) is still registered. If an interrupt fires after usbhs_pipe_remove() but before the driver is fully unbound, the ISR may access freed memory, causing a use-after-free. Fix this by calling devm_free_irq() before freeing resources. This ensures the interrupt handler is both disabled and synchronized (waits for any running ISR to complete) before usbhs_pipe_remove() is called. Fixes: f1407d5c6624 ("usb: renesas_usbhs: Add Renesas USBHS common code") Cc: stable Suggested-by: Alan Stern Signed-off-by: Fan Wu Link: https://patch.msgid.link/20260303073344.34577-1-fanwu01@zju.edu.cn Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -815,6 +815,15 @@ static void usbhs_remove(struct platform usbhs_platform_call(priv, hardware_exit, pdev); reset_control_assert(priv->rsts); + + /* + * Explicitly free the IRQ to ensure the interrupt handler is + * disabled and synchronized before freeing resources. + * devm_free_irq() calls free_irq() which waits for any running + * ISR to complete, preventing UAF. + */ + devm_free_irq(&pdev->dev, priv->irq, priv); + usbhs_mod_remove(priv); usbhs_fifo_remove(priv); usbhs_pipe_remove(priv);