Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp714090pxv; Thu, 15 Jul 2021 14:13:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJSq5K3QFmpSBg338URCGwN0kSzer19B6D+q1OcVBcJqu/P5LVsHLmbJK0MjckW5mVHo8v X-Received: by 2002:a50:cb8b:: with SMTP id k11mr9838888edi.55.1626383612416; Thu, 15 Jul 2021 14:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383612; cv=none; d=google.com; s=arc-20160816; b=lNZDYVBzt5vDS51YxEb95TqV8b4GyiX46x1Ib7UP4KJnN048K7FVXJFjAQ/STssSDN JiIVEnK8gszPyw3d9fedxia72V6ka9PhMHudUK6idVpciivLLmLqk5lIykv4TQ2nA8DM BakOrfkWjvmvz+GnD4BGb7dZK2JhJ+Ty20I/2Yha3owoP+5/kwyiF3bkALH1Ervf/L0r 3myzO507bWvjAmfQz2fX3WVMbV+GMWVgUqtIb0R9be33p2C27ABE8Zqsvq1zi2S/HNtZ qtR8PWra/LgBpye4mkWsvrT+qRg5nYa81y8g5JAvQJu+/kiJO1vidxWlnq4qnVlouVFB g7Jg== 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=g8vi88TusOZWgfcakq7FXqmEU9WzjInIpEjqZf1Y9x0=; b=JKPNvx2lN1Qk7JYdgz+hXm88UOXujqRrY3CjqHezmcv/0kgG+QEA2stJ21KqbsIZ7m osiAhpxYVyswJp+6XjAHaV2DZ4o+Bj4EvUWd3JngNZ0xETLoClXT1PSVac3rjKzBLfTi SpSxWOgI5DIEfkrczYpbHpSBFBqkINRiFbfe/3i22PQIp9bQ2776q/9Z/VGWAwKF7EE6 c1FS5gOwoDf8as4V0/2jPF0UQd5gQ5dEWJ8wO+dP9O+v0etBcRS3+LG5LoTWIfB8eQWm XXWUK3tIFKfrCqPG/214zymAg2dXFCxc+2i0UPAP4MT5nuuH7CkwxPp2FAUO5f/wczdb XZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mx0txGPI; 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 er10si8759324ejc.381.2021.07.15.14.13.08; Thu, 15 Jul 2021 14:13:32 -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=Mx0txGPI; 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 S1345008AbhGOTaj (ORCPT + 99 others); Thu, 15 Jul 2021 15:30:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:45710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237288AbhGOTIa (ORCPT ); Thu, 15 Jul 2021 15:08:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39D4D613DD; Thu, 15 Jul 2021 19:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375850; bh=1t40GFUdfFHXYov82Lchb4r/peMxoMO2yy/t5xvZifk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mx0txGPIYqIMESzSHXe7sU5209ypR+jsr2TqYeuw6c7VIIypJJYHaCamX6r7Ch5rC hSw3dqeD5XbS9nIJSEpeLtkHkWv/k+WOm7lfrXQdrxhIyuQGoji7BPB/bR1kfFnYJp Sr/2k59vWSmhT/a+FOQEwmZCGrnuOBc/RU9E6mOQ= 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 5.13 020/266] atm: nicstar: Fix possible use-after-free in nicstar_cleanup() Date: Thu, 15 Jul 2021 20:36:15 +0200 Message-Id: <20210715182617.476945810@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 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 5c7e4df159b9..b015c3e14336 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -299,7 +299,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); -- 2.30.2