From patchwork Wed Oct 19 08:26:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5066 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp248551wrs; Wed, 19 Oct 2022 03:43:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TAXFFrSRyYQu8d04xmRwwHVCLY634dOuvfjH/BQmPllI/H0jbobqqLLQ5+6I83JGiLR7R X-Received: by 2002:a17:902:d510:b0:185:480a:85d3 with SMTP id b16-20020a170902d51000b00185480a85d3mr8021689plg.4.1666176234428; Wed, 19 Oct 2022 03:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176234; cv=none; d=google.com; s=arc-20160816; b=zHWW9dWgiPja0HO5I50yNnkOwc3f0CrggE4pHeMXys68hMCE4bybS1rT2WwVoe/9Ae 30lgUpwhuqGu2uTt86PiZ7tV/PotsMUl77HmuKU13LU3GyzR07YrJTzeTSTC/jZDZGa+ woIGxp+KD5JAd+JIiInVLCjfwwXVTi/OnbBYerxyIw4PAWkrKpCZJpHPPu5Pyt474nFh rRVpOxH01nTfqLCNLGeMnrqcp74Pch3h/bSdNvqK3O3aOcS/ldzMJxNMg8Pxzcdmydto ZR33F/vERQTMCaxnZkO4sh04liFUM36NHW2oXgEXrzX57FtqkBQVwCZGRyYzfhWD6Z5q 6K8g== 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=KJVrexF1Subx3MagWsdrtcz7oEWbmoE2NJ/GIsmOsvM=; b=NWtL6BLj/a/+8GzYi92uHIZp0bJNTinqXU/qvzdg2DLQ8r6zMD8OaLqE+BRCFFaM2G aL5DpyCHx6iS5IMridh8bNRIwG2tRDqfG2pQYwE4wY3YDZQ1V+kTyqm9Cpksjij/MvUV Ru7Y4oaknByqmMkMtb+TWTCh9s5BJ1PX7PKvTtrAOLYu3KEnPqjZdmbIufPHP5f8cSYf MD4Hyeq57lfBnkW2hvsXtoNO2FhTtPJQ5NFsVuZ9JPKs46Bz0aNXkG6WldqTv5HoxFWY oS7+teg1QLcDI2yWrTBQybM0vvVv+C4kG9+tEbFTJCZUy9NwDZEIwV+DjPoqseuepIf3 SaWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s19ShQsq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a17090ace1600b0020038eb8b5asi16602600pju.21.2022.10.19.03.43.41; Wed, 19 Oct 2022 03:43:54 -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=s19ShQsq; 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 S232271AbiJSKnT (ORCPT + 99 others); Wed, 19 Oct 2022 06:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232242AbiJSKmX (ORCPT ); Wed, 19 Oct 2022 06:42:23 -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 4719BB97A0; Wed, 19 Oct 2022 03:20:10 -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 6ACB0B82389; Wed, 19 Oct 2022 08:51:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBB19C433C1; Wed, 19 Oct 2022 08:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169480; bh=CPeINRe0pEMnOWV5lqV0MslZCm4GwrZoEHYIiNvKaLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s19ShQsqy3POhaiw8YauC9RFXT9AqbJXVU92Mt7Q7qt2889cOZ6HaMgKFHlrkwE+x zDUzDv6sAC/gsd4ZvodeRCrwrutoUBO6WvBMV+Fnkyp8aomGgiI2Aucym4cI+FMUDC uV7kFr+Ced1yvDN4It9kLNwb57ZP9AWaYk6ngRH8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Deren Wu , Felix Fietkau , Sasha Levin Subject: [PATCH 6.0 292/862] wifi: mt76: mt7921e: fix rmmod crash in driver reload test Date: Wed, 19 Oct 2022 10:26:19 +0200 Message-Id: <20221019083302.915300879@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112410843573604?= X-GMAIL-MSGID: =?utf-8?q?1747112410843573604?= From: Deren Wu [ Upstream commit b5a62d612b7baf6e09884e4de94decb6391d6a9d ] In insmod/rmmod stress test, the following crash dump shows up immediately. The problem is caused by missing mt76_dev in mt7921_pci_remove(). We should make sure the drvdata is ready before probe() finished. [168.862789] ================================================================== [168.862797] BUG: KASAN: user-memory-access in try_to_grab_pending+0x59/0x480 [168.862805] Write of size 8 at addr 0000000000006df0 by task rmmod/5361 [168.862812] CPU: 7 PID: 5361 Comm: rmmod Tainted: G OE 5.19.0-rc6 #1 [168.862816] Hardware name: Intel(R) Client Systems NUC8i7BEH/NUC8BEB, 05/04/2020 [168.862820] Call Trace: [168.862822] [168.862825] dump_stack_lvl+0x49/0x63 [168.862832] print_report.cold+0x493/0x6b7 [168.862845] kasan_report+0xa7/0x120 [168.862857] kasan_check_range+0x163/0x200 [168.862861] __kasan_check_write+0x14/0x20 [168.862866] try_to_grab_pending+0x59/0x480 [168.862870] __cancel_work_timer+0xbb/0x340 [168.862898] cancel_work_sync+0x10/0x20 [168.862902] mt7921_pci_remove+0x61/0x1c0 [mt7921e] [168.862909] pci_device_remove+0xa3/0x1d0 [168.862914] device_remove+0xc4/0x170 [168.862920] device_release_driver_internal+0x163/0x300 [168.862925] driver_detach+0xc7/0x1a0 [168.862930] bus_remove_driver+0xeb/0x2d0 [168.862935] driver_unregister+0x71/0xb0 [168.862939] pci_unregister_driver+0x30/0x230 [168.862944] mt7921_pci_driver_exit+0x10/0x1b [mt7921e] [168.862949] __x64_sys_delete_module+0x2f9/0x4b0 [168.862968] do_syscall_64+0x38/0x90 [168.862973] entry_SYSCALL_64_after_hwframe+0x63/0xcd Test steps: 1. insmode 2. do not ifup 3. rmmod quickly (within 1 second) Fixes: 1c71e03afe4b ("mt76: mt7921: move mt7921_init_hw in a dedicated work") Signed-off-by: Deren Wu Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 2b015dacbba2..e5b1f6249763 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -288,6 +288,8 @@ static int mt7921_pci_probe(struct pci_dev *pdev, goto err_free_pci_vec; } + pci_set_drvdata(pdev, mdev); + dev = container_of(mdev, struct mt7921_dev, mt76); dev->hif_ops = &mt7921_pcie_ops;