Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp2219807rba; Sun, 24 Mar 2024 07:05:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqMqd3OxHQSoiZjAarx9WIZIt63TtCVF1R9NWswhi5FYbrEXDSIFKmp90JOT6dtItFwy1N8uMaXcSwawWykb/QldT+wpuAJXCqXOSLlw== X-Google-Smtp-Source: AGHT+IGYlsQJU3892mHAyFdWZTIt9BQFgP0WSxMe6PUslau2yln3wyRNa6rSA/JPJH/LwGPGOX8V X-Received: by 2002:a05:6402:c8d:b0:56b:fa95:ae2b with SMTP id cm13-20020a0564020c8d00b0056bfa95ae2bmr2355571edb.21.1711289148836; Sun, 24 Mar 2024 07:05:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711289148; cv=pass; d=google.com; s=arc-20160816; b=kxFFda5B+bRYPC3DKXMmto/2C4k0PcB/vDkH2sg9fd+bJpaXKMPYvQHP6TfiKpC0Oa LJ2ZLlgAdy0wO6+Q/d/6nUwA0s9qx9RaNZOXJrApJbmdDEWY7OedW6yt5KRWU5L6bxQS mwVse9dftLO0hpsW0Szagl79I36RD0AKUd9n4zw4DIDzCCufojE8dSbpIWsCq9d5g5KC 6TGtDgq8IM6EnCJlP2K2uZqIjBF58WvEkx4jEWL3+nbO5bUOvfEM+Gi4F52teaPFwYEF G5km3Z+VINVgUuiA5Lu4sRoIYo/Iex0KVxJgdoT8pAREufWCtDjj23NsmbyTvHnIFIgD rOsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=UjWfq2xalj1+cKBA3Y8vlBgrJngmTvM7GO/BIDFU10o=; fh=s943IumtNT8npL3G6scGxzqJ2zXhVYBbJysZbCienTc=; b=rc4MquvKZ2hUOZSiBVbrXE/zVIdXAC3RMCwxCZjsGRffRfYxAAykHd1mPgfcktm2OP qe/k+hh1Z+vjcxe1I7WWEDGNIlSc3/bhy2W31Lh/rpXapI4iHZknf1rt9Jy27LTdRv8v ClPb578bW9hplqLUsqjEC8OnB0w/hpxWuO4SjEnwsumnUZNlx7YTSxWypOQLiSHAS1Wb 1OxNNECrjVXG3b/XCY2gJNMIV2T5OZPYYCmwXObzgFI86lRCfWdE+RWIgQD0o6NkJdih zLWlgwfsnnQo0UBdXnM1J1nP1ZqNt8+fh/ZeyFewvPjcC9rVSdpsbLuFCsjdHzMS4QCW h9XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-112705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112705-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g12-20020a50d5cc000000b005689d5c4359si1623991edj.401.2024.03.24.07.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 07:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-112705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112705-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 90E1C1F213A3 for ; Sun, 24 Mar 2024 14:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA41E1803A; Sun, 24 Mar 2024 14:05:39 +0000 (UTC) Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E9BD17BD6; Sun, 24 Mar 2024 14:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.97.181.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711289139; cv=none; b=kMduMSdv6izfx0BCe32zk+dJGJtvndH+kfHWD8AS9nj7HeNu8Kyq0xWqFziJFu6QNofKZeVCUR8z1LW7Eqzwp3U64kwG3c11GTDUgSq4pe9WU6qjKOZrYueWmWVcpjcNfJV2kbxBbwVMDm/YwV3eBhaalPS/JlrOF9Q/lVSDy9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711289139; c=relaxed/simple; bh=o2gfx2M0LqqtCFmcmwNJmkgj/vYb5MeMt7l5rcKqAlM=; h=From:To:Cc:Subject:Date:Message-Id; b=VNougTvSzbYxU2oZjf+kbdfyfnMB56h/isGYH3Y7iu72/+zIrvNqetq8BDxL5VEnjbpzsKgIEwc5GWj7yObUPF9f+AMY6OU70EW4dr6pgOutKZVtufOTwcGtNsPaRAXe87KNE346xzaUSIvaNowxYeA4Gx+l/QrZ1+HrP3RDi6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=209.97.181.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [106.117.100.135]) by mail-app3 (Coremail) with SMTP id cC_KCgDX18H8MgBmd0YTAQ--.13126S2; Sun, 24 Mar 2024 22:05:00 +0800 (CST) From: Duoming Zhou To: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org, wim@linux-watchdog.org, linux@roeck-us.net, Duoming Zhou Subject: [PATCH] watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger Date: Sun, 24 Mar 2024 22:04:44 +0800 Message-Id: <20240324140444.119584-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:cC_KCgDX18H8MgBmd0YTAQ--.13126S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Jw4DAF4kJry8Xr15Ww1Utrb_yoW8JryUpr W8Jry2kryktrW293Z7ZFn8ZFW8u3sxAa4IkF1UC39a9Fs3Xr1fCFWrKr4jgFZrtFZ5J3y3 Xr10q345W34rXrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkG14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7CjxVAaw2AFwI0_ JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUSNtxUUU UU= X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwMJAWX+3hkBYwA5sP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 --- 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 688b112e712..9f279c0e13a 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.17.1