From patchwork Tue Sep 10 01:44:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koichiro Den X-Patchwork-Id: 1982887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X2mj765Vmz1y1C for ; Tue, 10 Sep 2024 11:44:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1snpvo-0000Ab-FX; Tue, 10 Sep 2024 01:44:36 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1snpvn-0000A4-JG for kernel-team@lists.ubuntu.com; Tue, 10 Sep 2024 01:44:35 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 2D6773F27D for ; Tue, 10 Sep 2024 01:44:35 +0000 (UTC) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2d88116d768so5351099a91.0 for ; Mon, 09 Sep 2024 18:44:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725932673; x=1726537473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yhYyBaAi/9HoRiQlthfqeYMOkQMPrUqOGPPNe1qRLrE=; b=AdqtgJ05/SJofHesPYbR9dyAJr0SHIr1/V44btTHKFerq96EN/xQKKq81rXGiXThlB KqFG8xBNxWT4UJDzQjd+8u3RwPtcT/MpC4jRwur2ypp4T+mPwdZJ5389nS8d8K0a9YlX dQPDU2R7HsJiUo3Q3Ek3Hj2uZXa6/5CvJA1cay1U1FNI6JvmL01lSlYGE/izF89e9hKd ukrXT17XE2XIC64gF6PMnpUf082X7c5Yh6FzVS6NHDiF02pPmATrn744aB8+WX974pNN tR0KvdZtcQATseRA6jUlkmaf/cCLZxhMSYrxle1FEThU8mZfGka3ChPTDmRSgoGtxy3H 77WQ== X-Gm-Message-State: AOJu0Yzm7QuSLutLJe/ThSaHG7pAStujc9GkH2BKgIr4x2/hJvSiGYoD e8DRx8XcYuh9vAoF54GZWdiSLGUFf3XFpcZtCL0PNJKg/7cr927G3N1GoVLMIlXokGu7fEomA/k i7KX2lDZF6cn/UmODA+3OCrkgUympL2jHaToxP3l4zkP5Jllw1T2CMFbL1mvkUeyFdFv7dWcoWs 4WD9MqAmHawg== X-Received: by 2002:a17:90a:f281:b0:2d8:8d62:a0c with SMTP id 98e67ed59e1d1-2dad4de156bmr13533855a91.3.1725932673632; Mon, 09 Sep 2024 18:44:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv/mwKPPurP+/dcnIu6F2iqC1Qxg9daVtpNMn4iqdGaxXx0lglVNfPEKqabPA+PpAstsEcSQ== X-Received: by 2002:a17:90a:f281:b0:2d8:8d62:a0c with SMTP id 98e67ed59e1d1-2dad4de156bmr13533841a91.3.1725932673168; Mon, 09 Sep 2024 18:44:33 -0700 (PDT) Received: from localhost.localdomain ([240f:74:7be:1:959:86f5:52c1:2a4c]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe471asm7371780a91.9.2024.09.09.18.44.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 18:44:32 -0700 (PDT) From: Koichiro Den To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/1] watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger Date: Tue, 10 Sep 2024 10:44:05 +0900 Message-ID: <20240910014409.1052185-3-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240910014409.1052185-1-koichiro.den@canonical.com> References: <20240910014409.1052185-1-koichiro.den@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Duoming Zhou 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 (cherry picked from commit 573601521277119f2e2ba5f28ae6e87fc594f4d4) CVE-2024-38630 Signed-off-by: Koichiro Den --- 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 688b112e712b..9f279c0e13a6 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);