Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3849893pxv; Mon, 19 Jul 2021 10:12:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvJo2/pyEkHt15BN+j0SM0YBXxZzSYLNbl9moZ6/RTAGLqRdNBLhfvcoxK21vUAt6acxzB X-Received: by 2002:a6b:1406:: with SMTP id 6mr19804658iou.25.1626714767463; Mon, 19 Jul 2021 10:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626714767; cv=none; d=google.com; s=arc-20160816; b=N1jF9BJYWw6T4WfENmVnQx/wFx2U2Bhdlboff7WmXyCo+f2779fEv7xfLyydYz+GU/ nRWYMRg7G5zqldUBBeM62dOBe1ZR+1yioK162QOHvF+A7oY2rNUbRB5W6ZE1Ti8aTfnz cTAu2PpLKWZ4qXjj1zneNr5ZWvXNnmDH8B06CZblVqbDPuZ21uSHsqiQf48j+nhDVwov FoIimM/nT+LqfEKpcn4TgGNgQWe5sl1vCesy7sOk5hmFtBwHwUtXUS7/oL54OOTuQiYr ur1+HJB1mF70+YJLD+LMRcI91Y62CpEhOBFxS9rssCPrr+OV7O7nfoDJhoU4Whg9IZBN KyZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LubXc1aJIn9ji2ad21cydRjuBYdLZ96R8bMcAPckig8=; b=HKZEm2jjvSoq/LogT7To10dwwEYiNCOi0pzQT3B7AulAyykwPpHOVHAnIzhQrzTP4o sJsW74Cpcz2bHZBUNbFzEPBIliX4GX/WyjCr7UNCXPEpvvO7lbWKfnYQss01/0kZC3qO Emqn1IauNgZLg1gY4moPS9vXwCwgkJP3+3+reFuNJqK4VOYQ0ejDhFm8zQC28gFqq+0i n5H4crtI9EGbHKC5011deQ6bWXN5bhg2rn5pASoaUIXzNsRYSFjRaoOTD88cDZO83XSB jiZVUSl54OzCq3ZwrDKMotYTM5ZdmSjzr4+Nl8hu/su1LCQvFksFhB1PJp+L+9JIPIjD /aXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e7PhVHrj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si21433498ilv.151.2021.07.19.10.12.35; Mon, 19 Jul 2021 10:12:47 -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=@linuxfoundation.org header.s=korg header.b=e7PhVHrj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350992AbhGSQbY (ORCPT + 99 others); Mon, 19 Jul 2021 12:31:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347420AbhGSPQQ (ORCPT ); Mon, 19 Jul 2021 11:16:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D33666120A; Mon, 19 Jul 2021 15:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710214; bh=xWCCHaF5NQH3bwlPXq7cZGPq7DcVswBFm6vzcPVvN44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7PhVHrjWgoof7vRroDLYy4sXAWKV0f//GRYUmPUbd88I4qAraSaKs5SNbw76nOhd T1qR1NSUnFU7Qo+SRjQ6eUXNVUS/abovEjD9CLGbymKwGV54B7D5BBXD0ppjrowlEo +UY+nXEwwVl5qBAGVcqbtMtveoc2MaCfOKpqYHaY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zou Wei , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 5.10 124/243] watchdog: sc520_wdt: Fix possible use-after-free in wdt_turnoff() Date: Mon, 19 Jul 2021 16:52:33 +0200 Message-Id: <20210719144944.912355790@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zou Wei [ Upstream commit 90b7c141132244e8e49a34a4c1e445cce33e07f4 ] 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 Link: https://lore.kernel.org/r/1620716691-108460-1-git-send-email-zou_wei@huawei.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/sc520_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c index e66e6b905964..ca65468f4b9c 100644 --- a/drivers/watchdog/sc520_wdt.c +++ b/drivers/watchdog/sc520_wdt.c @@ -186,7 +186,7 @@ static int wdt_startup(void) static int wdt_turnoff(void) { /* Stop the timer */ - del_timer(&timer); + del_timer_sync(&timer); /* Stop the watchdog */ wdt_config(0); -- 2.30.2