Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3414519rwa; Tue, 23 Aug 2022 04:30:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SjJgnJl9L0riyw/yNQ+Ji690kQ0Jv7s3CuiMhbIO25i164gwAEvh3rX1XQfV3E1ufyX+t X-Received: by 2002:a05:6402:5c9:b0:446:fb0:56bb with SMTP id n9-20020a05640205c900b004460fb056bbmr3358835edx.173.1661254241224; Tue, 23 Aug 2022 04:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254241; cv=none; d=google.com; s=arc-20160816; b=EDT7Y5RJOWzjVJM/OhLtN+jqHDVnOlkyoqaelwJAvSpIa+wbbhRK2SCsFmzZVSe4ht qGTD3+IbY6VGOkZ2mt6KWoIJdHoM9QHBCi+8OfbaMt2hB8v+ysd7ZtUS+Q82c3BxWGn0 l7uplkQpq6Br0AeuklsOps5vg7LOcnTf0b9RWaSKUpkGSiSzlsCz7h2DmW1hfac+Zzx1 9sghFeacvkdMW658qIMTuJn52yXfQC46I0RSChDURYXx05Oy71tttq98HDhXzTQNER5e 2vSeGdELqSLt0neuL+fmfhe6xxHzkAYNVEJi0zdHh4DPAZvM99GryLvnTPAHIeCp0X2Q NRHw== 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=srV50g793MNM4bEO5/ahv+9B7SCEECZZrY4+Qvs2kVU=; b=bww4MRJblPh/CaJhg9pvZPMHbI6pYihCH26Hc8JXr/c1FXrU1bsDGaxWSUQZv/8WlH NWV8PvVRdnxGaYxaoIcI/p6vfvQTXifqOgSFNuuh5xB2gtdYEWuzj15EfyfCcJR2/BiY VzSLDXR4EdHvRw98PXPstPMOY3DkCWK6qGDoCRFEVdF+dpdC6qduwBOZtxtP9y7l5uTr W5YxdeiS+P7zNu9FaSXLATCgcAChHJ/4ef6jZLg3eM+YdGzD07VbTTZcIysCeEO0Stsv 1lqJo7iSEtPckZlz6USgMklpIjF7Mna1ngysB0daRMZgdGs1F4reEShNM7kHVtrVxrWZ GXNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qVXg+DHI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a056402439600b00447225766cfsi1030310edc.535.2022.08.23.04.30.15; Tue, 23 Aug 2022 04:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qVXg+DHI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1356980AbiHWLEt (ORCPT + 99 others); Tue, 23 Aug 2022 07:04:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357427AbiHWLCW (ORCPT ); Tue, 23 Aug 2022 07:02:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5C4FB2489; Tue, 23 Aug 2022 02:14:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3ABB7B81C97; Tue, 23 Aug 2022 09:14:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88088C433C1; Tue, 23 Aug 2022 09:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246054; bh=BcWBC/MwhJc8WD0lLAzvzWux7J51PZtC2jJpLFzKH1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qVXg+DHI3T8/USlRXNDJN/SIvXSFA2GtxoKroJg4GAlAPClwte8b8y4CaigKjBT8K eeOnSIaSE9PSagOdgnzT8R6NbAfcoCwqQ7+YeRx5hdAyQ2P5Tb94ogJ2iS2EO45Z5C taodEKe9bO3mk8QB1b0V77eMAJJ9qM2XNt+2LbiA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Duoming Zhou , Jakub Kicinski Subject: [PATCH 4.19 243/287] atm: idt77252: fix use-after-free bugs caused by tst_timer Date: Tue, 23 Aug 2022 10:26:52 +0200 Message-Id: <20220823080109.291866469@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Duoming Zhou commit 3f4093e2bf4673f218c0bf17d8362337c400e77b upstream. There are use-after-free bugs caused by tst_timer. The root cause is that there are no functions to stop tst_timer in idt77252_exit(). One of the possible race conditions is shown below: (thread 1) | (thread 2) | idt77252_init_one | init_card | fill_tst | mod_timer(&card->tst_timer, ...) idt77252_exit | (wait a time) | tst_timer | | ... kfree(card) // FREE | | card->soft_tst[e] // USE The idt77252_dev is deallocated in idt77252_exit() and used in timer handler. This patch adds del_timer_sync() in idt77252_exit() in order that the timer handler could be stopped before the idt77252_dev is deallocated. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Duoming Zhou Link: https://lore.kernel.org/r/20220805070008.18007-1-duoming@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/atm/idt77252.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/atm/idt77252.c +++ b/drivers/atm/idt77252.c @@ -3767,6 +3767,7 @@ static void __exit idt77252_exit(void) card = idt77252_chain; dev = card->atmdev; idt77252_chain = card->next; + del_timer_sync(&card->tst_timer); if (dev->phy->stop) dev->phy->stop(dev);