Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2266439lqp; Sun, 24 Mar 2024 10:26:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPJkf7njulCycwCT1H69Zg9QpVaGeBiJr0PsskHTPf4yJ1zoh8UCKLxhyWXY6cgiUplxMBZR9qrVfWeahA390pyZ0TlxvOUPL1Dhvxvw== X-Google-Smtp-Source: AGHT+IH7Yt3EjnwRhUBjzMl0lME3BI3C2A4z28Ev3W1B8bUj6AHTxCBvUCINTsxkjHZIPf2mxZN/ X-Received: by 2002:a05:6830:11c3:b0:6e6:cd51:e87f with SMTP id v3-20020a05683011c300b006e6cd51e87fmr3336806otq.8.1711301164089; Sun, 24 Mar 2024 10:26:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711301164; cv=pass; d=google.com; s=arc-20160816; b=upkifCVu7QtCzaYXWsI/l/TWk8VjbAefKdmR6SyqArtyWTvHGIy5BIAE0iEXDz2yRH 85sgutJUr5nQXZ06ilHWzo9eA0z2VFgLA5UzaYKh0k8dJiWFvfy5VBR/lkekjrwDi4TW 3rQ113b4dkgkP2kJuAXk/b7RWUI4B/C8UnbovpFHRn8Fh0WrtBUlC4IAvipmzMlq9/5c VJfI0pqTFF56iAVk7qlec3PFoK0IAVu5isMz/y35Sy3ZSiATWZeWRQnSDWA2VCw1eLvN Jq0Qq0+1qlgnpTEig2x6mZJGnYxix1+sHwQpWq7RTWY27aVlm7T/3X18uj6Na2nE3+Qb RHXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=Cjhy1j6ng415mWwClf3r6vogHFOUJqIaXdUO0FgD+ps=; fh=CUgVZA7rWes1l1kbeaFHe8DO1xtR2ZNAGNuUiJJeUI0=; b=Oyi1ZgUSTfjm/FU3mG3CJM0YnK0yGKlphfn0ewi++pqVjse1AHJ3CMDuWwU83LNZ9/ zfbJ9H/qEEuKCOiFJkwQ4ZBWv+O9xe3bCSAgwyBbeg0Z6VaSWoGvYv2Vtf6ysxcQmhg+ 42a55J0DWijuDogMMA4Uj5Efc4giMUoLErN6qXbFjqXMhLhIOR42n6s2ued5lUXXKrnY 1xFv8sPPc8IwbCIE6zUJ+YTsiZVneKRAxTUmhFAbkpkCDkCSQLva2Cz+hOvHG7iCe37H QpcHTFko0fIW55UDdGN+I0wBpm8aSDlil1ypTyjdIIl1IH27B9U3DE0pVgWg1Aq3pEe9 sIwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YALZs97A; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112788-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f11-20020a6547cb000000b005d8fdbbd5d7si5961773pgs.606.2024.03.24.10.26.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 10:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YALZs97A; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112788-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 82BC1B20CFC for ; Sun, 24 Mar 2024 17:26:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CC6D199BC; Sun, 24 Mar 2024 17:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YALZs97A" Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C449F156C2; Sun, 24 Mar 2024 17:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711301152; cv=none; b=heSqkWe/78ybzNBEamgkrzYsNSsw1vYCCBDmCabWu2wZXU36VeREIwncWTjwObBUN8VB2ANhhFgxsGtr4LAk06CRS/4Is07Z0Bj6KjHGVGUewxqIcNXqBaedeQV9ahTQE5rCFXE9ZjyESk4R8RlrU3k5rAf7yH2JiH/zL1/YH2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711301152; c=relaxed/simple; bh=q+szx7jpSkgIelN9HKFrYdDXEUPrK1kQq9fG2zi8Oo4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k9zOCkwadnS5AsshCyR9gxkaWtBnL/CB5aEsPumXcKnfCnh8oIqq9mL5xSJF/2fhlZw45zzfzXLqbnVpXdI8IPUL69pKZTLOGNAVetGZ204Yn5X1qSiQKH0h5FRgHhwb1JeKQCv+2WjCqptO+txjhj+Ezvww27GzKO7tDIUQgdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YALZs97A; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5a46b28a77dso2106636eaf.1; Sun, 24 Mar 2024 10:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711301150; x=1711905950; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Cjhy1j6ng415mWwClf3r6vogHFOUJqIaXdUO0FgD+ps=; b=YALZs97A7BHOQNPpffNymdcerLWmqLOFZwVpmgwuhGc5kvBvo/mrdNkXYlAMLQwuhH yGH5o2PypqUUvPM+fmT9gIsFBKrdUZ+qKTDzlVYZnXAah8aIyXkZ+6PzUBcR/SomqEKU ibCUqcBYcTEvnlLgkZCKqEfVsit+YqycqsVvlDb3x7Qh2UEZSupT/dbxYXK3/Mqjg0pR d8Oj+9B0yE4r1fnBhxu9Jos7lINrO8JJMmgM0kP/K2i+tyvHW1w55MAjcu/nlybwMrIJ o/wGb0EKDqdKTATjcn44nfLe9SPEXdHVZz+M6rI/QtfFpcuGQxELTDXqfcEO62c1HtPV lAsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711301150; x=1711905950; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cjhy1j6ng415mWwClf3r6vogHFOUJqIaXdUO0FgD+ps=; b=cXXFrV/vhXfDEgGr4e0DQbkAv7Jiga+58k7N43P7yyTofKBuBQBp9r5mEXljsXO4fY 83yPn9mTxpfziuvEy2OFB0WRFQgGyrEGB8W9n+cEiqTzr4mqBcI3JV7QZD9NW69FnbbY 2edx7sFPaTRmuzLeh3wnaE95hE87BJK+460gXjEhK/UslFlpG/4A+Ulw9TuOSwyLT9ST Mrfc9PxxKJ4eBabS6AwgQ1wIYhFKznbzWWMC18TqS9/lKCOvajLCtdHHVqvk+Jo4twn3 PSdNSGtDsXj6fCMvwezEw+z3QZqJPYqxNaFwM/fp/WX58kAi2vr1fslOUiAonBbGOkgC r/oA== X-Forwarded-Encrypted: i=1; AJvYcCWfR8jGInKDFDeK5TK4rKhn+1gxHgfHzBFumRTTSBwYMRV0WMfLa1TtySCQtOLBwiG19JNwMx6kuP3pUG7b8EcnhBGd9arqGuUyhKMX/OM= X-Gm-Message-State: AOJu0YxT+r8KnnJGn9GktjxJe5wXnYfxLgwIDxs6g8N6bhyfXsXchc6s wISg/HM9XaCv7oi8U4rxn5KCfI1pAEtnD7OJmTEjk1iH453RgRJx+pliY+0C X-Received: by 2002:a05:6358:2813:b0:17e:b695:de64 with SMTP id k19-20020a056358281300b0017eb695de64mr6272557rwb.21.1711301149755; Sun, 24 Mar 2024 10:25:49 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id gl3-20020a17090b120300b00298cc4c56cdsm8710632pjb.22.2024.03.24.10.25.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 Mar 2024 10:25:49 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Sun, 24 Mar 2024 10:25:47 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger Content-Language: en-US To: Duoming Zhou , linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org, wim@linux-watchdog.org References: <20240324140444.119584-1-duoming@zju.edu.cn> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EArDlDShwR2+D+AMon8NULuLBHiEUQARAQABzTJHdWVudGVyIFJv ZWNrIChMaW51eCBhY2NvdW50KSA8bGludXhAcm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m6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240324140444.119584-1-duoming@zju.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/24/24 07:04, Duoming Zhou wrote: > 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 > --- > 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);