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 4045219E7FF; Thu, 6 Jun 2024 14:19:02 +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=1717683542; cv=none; b=oPNtZBIEaCCirqg33Pm/IfOW93PRuX1r2kn7jWLflidEfbADPdglY75dF2ybJPPkjdBRN0NNQOQVLrIu33WHJVI1jrtosXuVuK/W3rhuJFKYQXSkfZMw4NEwoY8tT2ExQhD6SYJdoxuUGKQEfTjFluz2CfCjYhCIq7ZxdwtW0Zk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683542; c=relaxed/simple; bh=jKaOuznwOkAeb8bezndi9NevhRm0yynTOC9qx8+/5K8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gF3idkF86hLMNBweZ5zAEuVzfC9+9qlM99nZn+t70ocii7ahKE4AxL8TO5m9+fT/DvmDYPENeQ2M8YfUrn1ZBOwNgb6dB8qSW80DP+Lvp0sYaLcYRoAPkvTfkFXNrYl6Q33vACJjs3zrQ7H7WOTNEMPsK4rC33cBJjt3bkdy96A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DT+9xPCn; 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="DT+9xPCn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EC48C32781; Thu, 6 Jun 2024 14:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683542; bh=jKaOuznwOkAeb8bezndi9NevhRm0yynTOC9qx8+/5K8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DT+9xPCnNxDldXdc19IXb9GW5FFNPT7J8dtTYcFvr2CTtJsI3ljYcIKlh3lVNqiIT KKREc7sEQgyX16ZlQTVWpkbgKuImmm8tpm6P2lJOPP287MiKXV1vFLu5gvbfwRSJ/4 DVWLmhdLdNqEeR99zM1ogRQssCSFVX9iczlmzN8I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Duoming Zhou , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 6.6 481/744] watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger Date: Thu, 6 Jun 2024 16:02:33 +0200 Message-ID: <20240606131747.891796524@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131732.440653204@linuxfoundation.org> References: <20240606131732.440653204@linuxfoundation.org> User-Agent: quilt/0.67 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Duoming Zhou [ Upstream commit 573601521277119f2e2ba5f28ae6e87fc594f4d4 ] When the cpu5wdt module is removing, the origin code uses del_timer() to de-activate the timer. If the timer handler is running, del_timer() could not stop it and will return directly. If the port region is released by release_region() and then the timer handler cpu5wdt_trigger() calls outb() to write into the region that is released, the use-after-free bug will happen. Change del_timer() to timer_shutdown_sync() in order that the timer handler could be finished before the port region is released. Fixes: e09d9c3e9f85 ("watchdog: cpu5wdt.c: add missing del_timer call") Signed-off-by: Duoming Zhou Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240324140444.119584-1-duoming@zju.edu.cn Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/cpu5wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/cpu5wdt.c b/drivers/watchdog/cpu5wdt.c index 688b112e712ba..9f279c0e13a66 100644 --- a/drivers/watchdog/cpu5wdt.c +++ b/drivers/watchdog/cpu5wdt.c @@ -252,7 +252,7 @@ static void cpu5wdt_exit(void) if (cpu5wdt_device.queue) { cpu5wdt_device.queue = 0; wait_for_completion(&cpu5wdt_device.stop); - del_timer(&cpu5wdt_device.timer); + timer_shutdown_sync(&cpu5wdt_device.timer); } misc_deregister(&cpu5wdt_misc); -- 2.43.0