Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409142rwa; Tue, 23 Aug 2022 04:25:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5wGa5UVvyP1X6PVHVuOhdfxue5VICRbgf/n8t2uQF5Fbe+H7uwHaApdtH3Ke1jvIQbIlm1 X-Received: by 2002:a17:90a:d14d:b0:1fa:f740:4aa5 with SMTP id t13-20020a17090ad14d00b001faf7404aa5mr2801566pjw.21.1661253899914; Tue, 23 Aug 2022 04:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253899; cv=none; d=google.com; s=arc-20160816; b=HfP6HlZggjEF8gVCvnnJsR5EEmBGJOGgHg/KcCOfIWAdcd6p3V1p7Nbn/lVq4VFQ3X EUmt+XiFpcyTmjwM0sllnwNTOuIHiLvVaMyKvaG4mZ94/6jL82MuS0OAIUITRe4eqVP8 0NjkXvERngBGSnKuZgWX1i2UhVUYniHE4sjD6JkiytZlAcHxsMVvH9f+euUJ1a6isysY Nnex8eFWt1BsVap7aa3sLRMw961CUbavDuwNNmKx9YC2lHxD6UBZpBtxiA5cuuqGrwoD KJuEuFISOHrM7HNhJwOJ6vceNYcK8UCtj40JMV5XzpQAZXrN0cOsEnBknkacxEqoXeUZ 0jeg== 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=rvSyr61Ep4L+PeAvAdK4uW5vo70T0MsYSfJZrOCPgbM=; b=w3sAOFrcN5vRXOtuZcQaKaXiOtWTsDVcL0lZy5o7LS9XT1X/53QxYDYLVR+stF6N1s YYl+XKkQNKQ/kuEBwFi014eYqZ7v2CyikHAnHSPOgSVbGeAMKJDPSN7NmMcFIeIkx4wq 9pGzA3r08dG/+3yQRzDdjcgpe4R/ao5JM9NGOh5RdqBEefoEsJaCkxWSEl2WiWSV8bvO yxUOoW0dhvwCiQpn3EB5HlgAOrm1pn6NIFEPmXHkgx2933fy01fjy8Aq7BQAaOtSNqku P3hg1pcfUmM8u2UezvqjZ2ASiOFmcxM5f+T+f5I8ufh2+A9CcX/VP94HwDe60gDYwDpG tfLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dc6sGkZL; 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 i189-20020a6387c6000000b00415d1eeabc6si14163976pge.344.2022.08.23.04.24.48; Tue, 23 Aug 2022 04:24:59 -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=Dc6sGkZL; 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 S1353824AbiHWKQC (ORCPT + 99 others); Tue, 23 Aug 2022 06:16:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352917AbiHWKG2 (ORCPT ); Tue, 23 Aug 2022 06:06:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF11311A04; Tue, 23 Aug 2022 01:53:35 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7C4566150F; Tue, 23 Aug 2022 08:53:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F700C433D6; Tue, 23 Aug 2022 08:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244814; bh=J7X6JkqhBQZ4uPFVbB5ZJDafAFxRbMj5SQrCvRAb4HU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dc6sGkZLsXhu1mSS7T2FACrqFnyYiK7osKLjsBtHLhXDvCfP41fRv8/0K0I9HrU/T MmHmjvpaqCS8Z5LUAik1tsst+e2He2iViww9qLtKpqxNISBYO8wzGZKrGMhV+eFypL P2Yk3W9ng8b/icLKS7ZgOo0H9vqAn93ezM3K5/as= 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.14 196/229] atm: idt77252: fix use-after-free bugs caused by tst_timer Date: Tue, 23 Aug 2022 10:25:57 +0200 Message-Id: <20220823080100.644156508@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -3768,6 +3768,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);