Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp43947pxj; Wed, 16 Jun 2021 19:49:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9RWjFfVR/b+Gr4ymmalDRRvJVarEqqg3Pu7mvia/RShBhopZks1Dnp/7nrfR1nsRly1ex X-Received: by 2002:a17:906:1f11:: with SMTP id w17mr2630599ejj.33.1623898140612; Wed, 16 Jun 2021 19:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623898140; cv=none; d=google.com; s=arc-20160816; b=hLrBTMS4ywS/b/c3n1oUjiR/4zcLQ2pjnhnigunnr0bO0HfKFMcLmsP0tAD7ZB3U0w RHIm1fl3kPLRNnRxNHXfV21pl7oxPxuPO/m9bMRLEot6TnxnEdlLSkM8ex/qSh7rrkTe Tt6yXlcDsEAwjtPv7zn5+n+mkBN6tzhCCJO8LfzuJ9syVQXoV79xKYwICNy42/9PITjO Qgtow/v2G5iGM2zFpIFyLvSYn3jTs1MMYz8FIaQ2riuUU3hfVCqeoZkXVqaB8XhTpm2Z 39c4z1MwtOYEqFU4GqA0ZDNqIGGazFnAzhXtxLJ/651wxX7uagA+c/MMH7OVipZhAg19 VO4A== 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=COn7zPM4kHVNOqGqkq+vloRu31xLYjpmdtILKPhWLes=; b=mLJkbIPlSx5vy/+XSqZuFs0A12UBGSrW92KPGXVgTD8derREY4kh4eV4k6Hz9VaSUU 2OzRVgasQuqpA9Ju/p/4YguwAYgA6yzea0k8RPsvK1zZsoRJC8h8RMJIwxW85qIASUyn 72Vz0/OpkRzY6v9t6n+uNWGp8AHaaWkOqWJdBwwDg3fpJMdoo5To8TGoKleQrA1C97Y/ ZYqBsZWVoN3NG0Y9+lCS99N+R0rZkMsD4r2+7YwfcWjB7xhdzMoTrjUzXuISOZUSLqnv 0xkBRSnFiXdXKn2UvEn7fJ3ftDjR+2VnyOBgBQGssGrUjdZCcIFWcquZwYjE1Vxbjhpc xo1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si3777609edt.22.2021.06.16.19.48.36; Wed, 16 Jun 2021 19:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbhFQBlh (ORCPT + 99 others); Wed, 16 Jun 2021 21:41:37 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:55568 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229713AbhFQBlh (ORCPT ); Wed, 16 Jun 2021 21:41:37 -0400 X-UUID: 46ac3d6201de4faaa4227846d2e4ea1a-20210617 X-UUID: 46ac3d6201de4faaa4227846d2e4ea1a-20210617 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1988424041; Thu, 17 Jun 2021 09:39:27 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 17 Jun 2021 09:39:20 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 17 Jun 2021 09:39:20 +0800 From: To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH] mt76: mt7921: fix the coredump is being truncated Date: Thu, 17 Jun 2021 09:39:19 +0800 Message-ID: <2ebb95099102ffe62c0fa8aedd95d7e77b5ca385.1623884856.git.objelf@gmail.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Fix the maximum size of the coredump generated with current mt7921 firmware. Otherwise, a truncated coredump would be reported to userland via dev_coredumpv. Also, there is an additional error handling enhanced in the patch to avoid the possible invalid buffer access when the system failed to create the buffer to hold the coredump. Fixes: 0da3c795d07b ("mt76: mt7921: add coredump support") Co-developed-by: YN Chen Signed-off-by: YN Chen Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt76_connac.h | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h index 9b3f8d22f17e..d93ab1ece8ae 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h @@ -13,7 +13,7 @@ #define MT76_CONNAC_MAX_SCAN_MATCH 16 #define MT76_CONNAC_COREDUMP_TIMEOUT (HZ / 20) -#define MT76_CONNAC_COREDUMP_SZ (128 * 1024) +#define MT76_CONNAC_COREDUMP_SZ (1300 * 1024) enum { CMD_CBW_20MHZ = IEEE80211_STA_RX_BW_20, diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index fb4de73df701..905dddbfbb0b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1557,7 +1557,7 @@ void mt7921_coredump_work(struct work_struct *work) break; skb_pull(skb, sizeof(struct mt7921_mcu_rxd)); - if (data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { + if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { dev_kfree_skb(skb); continue; } @@ -1567,7 +1567,10 @@ void mt7921_coredump_work(struct work_struct *work) dev_kfree_skb(skb); } - dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, - GFP_KERNEL); + + if (dump) + dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, + GFP_KERNEL); + mt7921_reset(&dev->mt76); } -- 2.25.1