From nobody Fri Sep 5 20:16:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB5C6C32772 for ; Tue, 23 Aug 2022 11:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359135AbiHWL7m (ORCPT ); Tue, 23 Aug 2022 07:59:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359330AbiHWL4i (ORCPT ); Tue, 23 Aug 2022 07:56:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2131CD6B85; Tue, 23 Aug 2022 02:34:15 -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 91657B81B1F; Tue, 23 Aug 2022 09:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04207C433C1; Tue, 23 Aug 2022 09:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661247253; bh=AUDeBJ3ci24Kx2P8cQDC+D1+oJ3UL+YG5IlIBBeZe9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfS+Q4iZw2QJy2h+J+PHcEwzsnnkpCU2dyEZnoGYWacxjJXAUOQpQ0OgX6A29Mo7K KMC6FOj6/WVarjx5fnOnGm5CM132AMTtCVUZPRqVPPH6nG3TO30m35P00p+oaGZ015 KP/jv8xxr4pEpXeb45UfDMh1oT0rtouTU/nvy6Og= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Duoming Zhou , Jakub Kicinski Subject: [PATCH 5.4 326/389] atm: idt77252: fix use-after-free bugs caused by tst_timer Date: Tue, 23 Aug 2022 10:26:44 +0200 Message-Id: <20220823080129.129755992@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 @@ -3766,6 +3766,7 @@ static void __exit idt77252_exit(void) card =3D idt77252_chain; dev =3D card->atmdev; idt77252_chain =3D card->next; + del_timer_sync(&card->tst_timer); =20 if (dev->phy->stop) dev->phy->stop(dev);