Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3531425pxj; Tue, 11 May 2021 06:38:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIuP4u8FEMwia4/6Q6lkHkvlwnUpJhzEdeUkIG9TeKnvO4EIXUMCoC/id7yfXl28mgtLR4 X-Received: by 2002:a17:906:374b:: with SMTP id e11mr31952336ejc.328.1620740322829; Tue, 11 May 2021 06:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620740322; cv=none; d=google.com; s=arc-20160816; b=ZWXjsPVPBpm9S5QNm+0ABcu6+1M6VtIWW2eZI+9ntRcG4juWI69Jhmsi9RhRnM0jFl oWuZBJbtMczhW5C/pfkDLM4Bb3pjrGdN9+LoC2mOFgRTRBmAgLtM2o7Zmzo+WcZC9TLp r2/2Z47bBib/YMgvIsJ+Z491003EdXZcgMLNlOrMc5IiufzjN4cphof/L9SKtMlVGnCg 8xJyJVaL2kBbhST3bEVnDILh8njfRaYmvtmjdM4z9VTkll3PW5hP3QwOgb8eBF+8U8ZG KJFdjqnj4Rqpg36yDddfFr6nsEl7oJOU7DeQFReLaF9Ol3ztBrCrXQ7QSE3Y2KyZaeaU isig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:sender:dkim-signature; bh=8PKRMx9MBXWK8U7e2Oztbh2Zz7bPL2jV0MPHBiguWvc=; b=oAzC7n+f82Ind17mz4yfxh014p+nRQaAsboy8ae9273H6srty2+jm9DOuVEIIn0PXw 1IMCzuLW8mO3iP8wH8wuAu8caAhtU0PW2lR4DF2RfpTa+SaZ0CW+0HHX7eNtFgipfTES +t0dfvmMEr09a1hNtM44BykDXoXH7BN9AbKnu546GZxP9Ai5V4LqIZaChgRdsI7ySzEY 5yr/BrdWfU9OJRghKRjnzcR+hoOsXFW95XOLZC1lf9O6e5xuyRqObM9DDuv2EtN1TEoM TaissXC84euyO9m4fxjDDLrq/5bYo28sssdfPT1QiBe1dnjU1DObzkaN4lj+IK7D7cSY QGhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XYvWl+o0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si2471854edd.181.2021.05.11.06.38.18; Tue, 11 May 2021 06:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XYvWl+o0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbhEKNiS (ORCPT + 99 others); Tue, 11 May 2021 09:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbhEKNiP (ORCPT ); Tue, 11 May 2021 09:38:15 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD08C06138C; Tue, 11 May 2021 06:36:57 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id n32-20020a9d1ea30000b02902a53d6ad4bdso17493233otn.3; Tue, 11 May 2021 06:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=8PKRMx9MBXWK8U7e2Oztbh2Zz7bPL2jV0MPHBiguWvc=; b=XYvWl+o0fvuB7esKnRXswPCiu2rFCTLOo76GEBksBu+X2qlKTM+fkaFutoCbjffE0o D8IHVh8CHppDAzaQRzop3vzltv+107H4xeCTCiNcwpQRX5IG7/NRo73VwEhFnytWfGmf aT3Oaj5/9AOO0T3OtFnB2bbMlYU7CaPMWw5tZlBijrl42XJjfs2uYGF3TqSfyUCTdnO8 3e2PaQKHr006GWUbCXIH5gmi22w4pb4t1j59S7phRJJBQ+CAZvv060hSnMIE537UaHvV I0CsmVQaqlXgTpb6HUmbl8c7CCOj580siuvAEohvNoNEHqR/c/Xw/ZwCqXqxp0N5FL+H FP4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8PKRMx9MBXWK8U7e2Oztbh2Zz7bPL2jV0MPHBiguWvc=; b=VW0QFST9rEDqLptiwRXqIVfFyNvQlsR3gFk8TqBCP1Sb4XUnIw3Ny43M/qrKfQNTa6 6GN3h82GBYz+w9bBoASp0nWW/HK58OrZegN3x8Q4eMM28+lTXF2p8CiEf6vqUCWDvmbC SkZoCA3h8E604NMEU3eccuZDsHyYdFIJaWfnA5UnxcMr9Wg5kFa7OuQG5ETWmB/UALPK nevzZSYqULJkhbXrwihvt+WwRc75j0XWwYGiPJImZn9YPy1PPkCS5YCdBTdzJIjArLos QlPNkKa3ooNRSrTf/s54gyt/4S6H4egKHO+WOfcl0mTpuCty2xog1TDBSBXKY8xNcgI+ 6Byw== X-Gm-Message-State: AOAM532kPcK53LJPazLJAUWgNxs2OwjpEAy/ryzeaSSmMOtL3yhhei8t H3ALfPq4p4FSbCBumoQHaDy3I6/wkp4= X-Received: by 2002:a05:6830:611:: with SMTP id w17mr12208512oti.225.1620740216340; Tue, 11 May 2021 06:36:56 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e7sm1871861oos.15.2021.05.11.06.36.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 May 2021 06:36:55 -0700 (PDT) Sender: Guenter Roeck Subject: Re: [PATCH -next] watchdog: Fix possible use-after-free in wdt_startup() To: Zou Wei , wim@linux-watchdog.org Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org References: <1620716495-108352-1-git-send-email-zou_wei@huawei.com> From: Guenter Roeck Message-ID: <3862c1d1-dd78-0b80-74c4-5f32a821fbef@roeck-us.net> Date: Tue, 11 May 2021 06:36:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1620716495-108352-1-git-send-email-zou_wei@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/11/21 12:01 AM, Zou Wei wrote: > This module's remove path calls del_timer(). However, that function > does not wait until the timer handler finishes. This means that the > timer handler may still be running after the driver's remove function > has finished, which would result in a use-after-free. > > Fix by calling del_timer_sync(), which makes sure the timer handler > has finished, and unable to re-schedule itself. > > Reported-by: Hulk Robot > Signed-off-by: Zou Wei Reviewed-by: Guenter Roeck > --- > drivers/watchdog/sbc60xxwdt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c > index a947a63..7b97480 100644 > --- a/drivers/watchdog/sbc60xxwdt.c > +++ b/drivers/watchdog/sbc60xxwdt.c > @@ -146,7 +146,7 @@ static void wdt_startup(void) > static void wdt_turnoff(void) > { > /* Stop the timer */ > - del_timer(&timer); > + del_timer_sync(&timer); > inb_p(wdt_stop); > pr_info("Watchdog timer is now disabled...\n"); > } >