Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8325557rwi; Tue, 25 Oct 2022 05:29:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hxVOjzCfj6zJCyncdmxht2gDn/Daaq2L/N+urAniijUXIxMPi3pqy3oV6rdjj3BCSled5 X-Received: by 2002:a17:903:1109:b0:179:d220:1f55 with SMTP id n9-20020a170903110900b00179d2201f55mr37766201plh.42.1666700951210; Tue, 25 Oct 2022 05:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666700951; cv=none; d=google.com; s=arc-20160816; b=opj+vDWKWvOqxj8sfM7iwwWMvO473nlPj5sdaXNDpa4ERGcaq+4LzxSFEhCi+ML5MS II36zM+alj/5UNssT6VFvC7hNS50nqKTvNmdAjBwDwrYNC2QD4eoQt+RNu9dKqrUWaeR f3T6K2fAFpuhV7H3B5uCuMQVYXhBmqZtlKpsrS+KPxyt6AjaLqQImQRHlr9lfJi2mF+1 dplfphN+bwFqHAO2xuI1MPax60JSdo4kNbaHJUIyyiOiCJsjoLuANhZE0fbm2VSN+mKa 3sIf7GMKGb1+y5GQF4nL3pGDUvGP3osuHqsZ1GVsVdAh6bsNpdG7hvOgh6kB3cZFO0DC QeOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=urD3NYRU0tD5nMUZc8WuEtyFV6UL1mj8zdIX2vw7/30=; b=CmKYm+5DgOt7/BOcuynja4oEEyDsh1Qzxt6uDs/+sKO315ECJMpdI5dLpkou1S/TV2 7LFu879zKj9lCNDI/v0EePpxlYCJmR1xqEE/a8lTATBQJ0w7/NwusAPPDxx4JqAuMsv2 9+yxS9RJv4sWPLbnt0VMpJ8+XBpjy2tNrzllT6AZf+t6G/NjVj/du93TjQKvbzZ4C1i6 0cwpQ3CkuWC6DyrW/6xEgB+bNeR6T3YTji6gbIB3qFk85aYH+SSe4t4RfWD/ybpOIIaf ImZi+uKBTlnMP2cc6pSSZ4KyaF7R9ZWq1uAHc8z4oc75Uwm7fQTdbPRVAfEzrC78/p8k CjsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a170902d65200b00186748fd1a9si2506040plh.170.2022.10.25.05.29.02; Tue, 25 Oct 2022 05:29:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbiJYMZV (ORCPT + 65 others); Tue, 25 Oct 2022 08:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiJYMZQ (ORCPT ); Tue, 25 Oct 2022 08:25:16 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652D2CF85F; Tue, 25 Oct 2022 05:25:14 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MxWNX1DrqzHv52; Tue, 25 Oct 2022 20:25:00 +0800 (CST) Received: from huawei.com (10.175.101.6) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 20:25:11 +0800 From: Zhengchao Shao To: , , , , , , CC: , , , Subject: [PATCH] wifi: mac80211: fix general-protection-fault in ieee80211_subif_start_xmit() Date: Tue, 25 Oct 2022 20:32:50 +0800 Message-ID: <20221025123250.143952-1-shaozhengchao@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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-wireless@vger.kernel.org When device is running and the interface status is changed, the gpf issue is triggered. The problem triggering process is as follows: Thread A: Thread B ieee80211_runtime_change_iftype() process_one_work() ... ... ieee80211_do_stop() ... ... ... sdata->bss = NULL ... ... ieee80211_subif_start_xmit() ieee80211_multicast_to_unicast //!sdata->bss->multicast_to_unicast cause gpf issue When the interface status is changed, the sending queue continues to send packets. After the bss is set to NULL, the bss is accessed. As a result, this causes a general-protection-fault issue. The following is the stack information: general protection fault, probably for non-canonical address 0xdffffc000000002f: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000178-0x000000000000017f] Workqueue: mld mld_ifc_work RIP: 0010:ieee80211_subif_start_xmit+0x25b/0x1310 Call Trace: dev_hard_start_xmit+0x1be/0x990 __dev_queue_xmit+0x2c9a/0x3b60 ip6_finish_output2+0xf92/0x1520 ip6_finish_output+0x6af/0x11e0 ip6_output+0x1ed/0x540 mld_sendpack+0xa09/0xe70 mld_ifc_work+0x71c/0xdb0 process_one_work+0x9bf/0x1710 worker_thread+0x665/0x1080 kthread+0x2e4/0x3a0 ret_from_fork+0x1f/0x30 Fixes: 107395f9cf44 ("wifi: mac80211: Drop support for TX push path") Reported-by: syzbot+c6e8fca81c294fd5620a@syzkaller.appspotmail.com Signed-off-by: Zhengchao Shao --- net/mac80211/iface.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index dd9ac1f7d2ea..5a924459bfd1 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1900,6 +1900,9 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata, IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE); synchronize_net(); + if (sdata->dev) + netif_tx_stop_all_queues(sdata->dev); + ieee80211_do_stop(sdata, false); ieee80211_teardown_sdata(sdata); @@ -1922,6 +1925,9 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata, err = ieee80211_do_open(&sdata->wdev, false); WARN(err, "type change: do_open returned %d", err); + if (sdata->dev) + netif_tx_start_all_queues(sdata->dev); + ieee80211_wake_vif_queues(local, sdata, IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE); return ret; -- 2.17.1