Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp64109rwl; Wed, 9 Aug 2023 10:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErO0lEf6szDggOJYXJEPVZ4WxZwzpFABYi4RJuTMOOH7GMQOoGL+xwGHz9XUp5etY3YSLB X-Received: by 2002:a17:90a:7bc5:b0:268:e30e:e92f with SMTP id d5-20020a17090a7bc500b00268e30ee92fmr180731pjl.18.1691603990830; Wed, 09 Aug 2023 10:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603990; cv=none; d=google.com; s=arc-20160816; b=Xqo58XaSaBbVy2GKx12CgXUvTko8nyTtE/Q1syF4FeCzJloSKULKOtthLu6bQ3VQkk OhPezNOvqROqKAnIYtZ/vsJAE/8LVej+asRW5M7bH8IDigJnskaghx8bZ1+FAMk8LTJR WvU8U06V02o/GHQd683D+XGzMe90ROQr7mr00g4kmxPvtxnvIAJn0YruTGGWkptzsqeB sJLJzzwyRrcWhIGC0dYnFEqGPNXi1u/UoHCFrWBI6pSlIpCXMn3u6XxQNnGg80l3omFQ 41+1xdWmaAp937V47ATNdJd8ZVl3+P2HpC9j9h2zQKlzGRzIITkH4tGEMDzLs/7PFbHs Rwsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6AHvfRviNYYMLqCQhBtcOKnIbQvezgBEt2zxX8gATyA=; fh=E3Iarn/XsCrb/4Ra+KWAunDuTgPSal5bueh3VkdxGkI=; b=Ge7mMUIMqUKfVB2YKA77MfuD6yZ4kybfsFVCTacufFDi+e9Tp9KkjVFKEmohXMKJJD b9Y+Qp4sgVRjmV99qpuDe50SUAfYfP0xsGHuPoyWVYq4epwz9EhOvCyhpzrD4Dn29zdQ MQRJWWRn1+VcYiqjmrozVHdCo7nXh1JclBwYEc8xNDh/VztJvlVe1KCBTPloU+GjrGRi fZ6y3MKR3sM15pl07RiZgl0xC3iVc9NoMmCbkckzmgaG4bAw1BJXoP1iyONjdg+ZBO8p PXm3twVX9XhJcCStoxyHSowAKTiSeduI6CMGLocqemw4mCboORWFXwObBC4oduGHnDg/ Vk2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SyM+Ve0Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a17090ab28200b00263419c5c00si1767180pjr.50.2023.08.09.10.59.29; Wed, 09 Aug 2023 10:59:50 -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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SyM+Ve0Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231901AbjHIRcm (ORCPT + 56 others); Wed, 9 Aug 2023 13:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjHIRcm (ORCPT ); Wed, 9 Aug 2023 13:32:42 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69E68E for ; Wed, 9 Aug 2023 10:32:41 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 379H0Xmi022716; Wed, 9 Aug 2023 17:32:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=6AHvfRviNYYMLqCQhBtcOKnIbQvezgBEt2zxX8gATyA=; b=SyM+Ve0Y3FFSniJO3YNIQjgF6Zh4AIDeaVGJko45sQ55lBVoAU1JLd4U9beIRH/0Cd7n IsIFDZqJXbtbx3vgsXX1nxcbm9O031DhVWVup9mXZv0wgGOOjW6Z/xClEqjimW1Pvu5/ HM7HhdHAzGtAdZYLUkYCUrF1J60SExnfSqxC4r/HYnQtdAZ0iKFXsbMZJeCVEQPcCJIt kysKWg4Sng4mKEGlcieJolqttek7DZFBzCI1M1ecKcBI+g9WAsNPXRfcDjEwCbfnYTlR tefS6eMFDg2APbxEJs9xFcCkUzeZ7B3J4+ROQ01imx88Nvx24zGD1CtGKJZlqXFOjuE8 Gw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3sc00522sh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Aug 2023 17:32:37 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 379HWaZM026475 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 9 Aug 2023 17:32:36 GMT Received: from [10.111.180.219] (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 9 Aug 2023 10:32:35 -0700 Message-ID: <3d022dad-99b2-0b4e-adab-4ac5147c989c@quicinc.com> Date: Wed, 9 Aug 2023 10:32:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] wifi: ath12k: add check max message length while scanning with extraie Content-Language: en-US To: Wen Gong , CC: References: <20230809081657.13858-1-quic_wgong@quicinc.com> From: Jeff Johnson In-Reply-To: <20230809081657.13858-1-quic_wgong@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: fEucNUWo4bI6GhE1lbm15JeNeJ6YWFsp X-Proofpoint-GUID: fEucNUWo4bI6GhE1lbm15JeNeJ6YWFsp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-09_14,2023-08-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308090153 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 On 8/9/2023 1:16 AM, Wen Gong wrote: > Currently the extraie length is directly used to allocate skb buffer. When > the length of skb is greater than the max message length which firmware > supports, error will happen in firmware side. > > Hence add check for the skb length and drop extraie when overflow and > print a message. > > Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 > > Signed-off-by: Wen Gong Reviewed-by: Jeff Johnson > --- > v2: seperate to another patch per johannes. > > drivers/net/wireless/ath/ath12k/wmi.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c > index 9ed33e2d6da0..e964d6003ea9 100644 > --- a/drivers/net/wireless/ath/ath12k/wmi.c > +++ b/drivers/net/wireless/ath/ath12k/wmi.c > @@ -2240,12 +2240,6 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar, > if (arg->num_bssid) > len += sizeof(*bssid) * arg->num_bssid; > > - len += TLV_HDR_SIZE; > - if (arg->extraie.len) > - extraie_len_with_pad = > - roundup(arg->extraie.len, sizeof(u32)); > - len += extraie_len_with_pad; > - > if (arg->num_hint_bssid) > len += TLV_HDR_SIZE + > arg->num_hint_bssid * sizeof(*hint_bssid); > @@ -2254,6 +2248,18 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar, > len += TLV_HDR_SIZE + > arg->num_hint_s_ssid * sizeof(*s_ssid); > > + len += TLV_HDR_SIZE; > + if (arg->extraie.len) > + extraie_len_with_pad = > + roundup(arg->extraie.len, sizeof(u32)); > + if (extraie_len_with_pad <= (wmi->wmi_ab->max_msg_len[ar->pdev_idx] - len)) { > + len += extraie_len_with_pad; > + } else { > + ath12k_warn(ar->ab, "discard large size %d bytes extraie for scan start\n", > + arg->extraie.len); > + extraie_len_with_pad = 0; > + } > + > skb = ath12k_wmi_alloc_skb(wmi->wmi_ab, len); > if (!skb) > return -ENOMEM; > @@ -2343,7 +2349,7 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar, > tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_BYTE, len); > ptr += TLV_HDR_SIZE; > > - if (arg->extraie.len) > + if (extraie_len_with_pad) > memcpy(ptr, arg->extraie.ptr, > arg->extraie.len); > > > base-commit: 3f257461ab0ab19806bae2bfde4c3cd88dbf050e