From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C7A6C07E9B for ; Sat, 10 Jul 2021 23:56:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 891646135E for ; Sat, 10 Jul 2021 23:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234327AbhGJX6w (ORCPT ); Sat, 10 Jul 2021 19:58:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234348AbhGJX5r (ORCPT ); Sat, 10 Jul 2021 19:57:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3193C6141C; Sat, 10 Jul 2021 23:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625961169; bh=Z1n8wsZv+jOd5MN9VkohCRg6WHiM6xigm4+S3agCXjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hdlA53HQ55OHJBd49EgtXKAhF9Ec7G4aBVc8MDCawb83igstHaPkAZkONyaPIeF0R wvm/2kkgIezXPc2v48F7qxu0vrdgXVMzH8gOe1p0DTxeftxWRwBAzIMWzdOAtAzvqF /kt503SnoNb4Zbj3rYKhNk6Qn/zsqsjuq+uN6GRK01+yNvJevDJ4EWcajapleohkoC +chGdwi5cixilmyDtD6neWz+JiKvhbbIyHohqraQzeXh2dlWV+AzB86p6h3gKK/rcS GyXqUipxX1ju55GjqEVYS+0x86l/d+8nuPk4z0+P/r66eNpb1ZWfV8w9PGxGKsc5k4 3TYVIUE/dXKcQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zou Wei , Hulk Robot , Guenter Roeck , Wim Van Sebroeck , Sasha Levin , linux-watchdog@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 06/16] watchdog: sc520_wdt: Fix possible use-after-free in wdt_turnoff() Date: Sat, 10 Jul 2021 19:52:30 -0400 Message-Id: <20210710235240.3222618-6-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710235240.3222618-1-sashal@kernel.org> References: <20210710235240.3222618-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@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 1cfd3f6a13d5..08500db8324f 100644 --- a/drivers/watchdog/sc520_wdt.c +++ b/drivers/watchdog/sc520_wdt.c @@ -190,7 +190,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