From patchwork Mon Jul 19 14:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 481318 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 8E0B8C07E9B for ; Mon, 19 Jul 2021 15:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7799061166 for ; Mon, 19 Jul 2021 15:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243442AbhGSOb2 (ORCPT ); Mon, 19 Jul 2021 10:31:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:38286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244325AbhGSO3f (ORCPT ); Mon, 19 Jul 2021 10:29:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A77E61175; Mon, 19 Jul 2021 15:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707356; bh=74C5aP2MRQm3l9T1LtY5KYwJPaw49ai4Asw0Zt0nA3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYxx1SgKu+oZx6PzT3we34I/Ra2PcEe8F9qU+5mCsOgN8TT3EdbC2jsVJ3MyUfV5Y 4/AIXjCPNfSxn6Y2vtZLnwpqtJGCORFeP7WP6C/GwVpzpuW6sQmz+7SMPHXQOTga34 BJaqayKPbSdI08WUikS4qDY2dhPaag70tuYDmroI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zou Wei , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 128/245] atm: nicstar: Fix possible use-after-free in nicstar_cleanup() Date: Mon, 19 Jul 2021 16:51:10 +0200 Message-Id: <20210719144944.543748013@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zou Wei [ Upstream commit 34e7434ba4e97f4b85c1423a59b2922ba7dff2ea ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/atm/nicstar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 8bcd09fb0feb..b2bae94ffe4d 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -298,7 +298,7 @@ static void __exit nicstar_cleanup(void) { XPRINTK("nicstar: nicstar_cleanup() called.\n"); - del_timer(&ns_timer); + del_timer_sync(&ns_timer); pci_unregister_driver(&nicstar_driver);