From patchwork Tue Dec 8 15:09:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaohui Zhang X-Patchwork-Id: 11958785 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 049D8C433FE for ; Tue, 8 Dec 2020 15:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC26A23A75 for ; Tue, 8 Dec 2020 15:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbgLHPMV (ORCPT ); Tue, 8 Dec 2020 10:12:21 -0500 Received: from mail-m975.mail.163.com ([123.126.97.5]:56492 "EHLO mail-m975.mail.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729514AbgLHPMU (ORCPT ); Tue, 8 Dec 2020 10:12:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=SNfMS57SQ/9kcHp3Cs Z830nUpvVEC6Ph3YJtof5sGEk=; b=e1vo6C0dXm3t+EB0GWLJv2AZ/H9PC4ixpk Zz9DJ8fWfKVOzu3ZLM8GvKm1b0hEIl7wOLMKuG95/U1L+xE8ngamF3cNQVfIYjyV SLvhpS5c+8B2tP1ljb69CsT5Ms+xy7q2jhVkX12DGeOyAEGrTLDzeo/SeeEZZRWx uVOqCd9ZI= Received: from localhost.localdomain (unknown [202.112.113.212]) by smtp5 (Coremail) with SMTP id HdxpCgC30WdDl89fT5mvEA--.5983S4; Tue, 08 Dec 2020 23:09:57 +0800 (CST) From: Xiaohui Zhang To: Xiaohui Zhang , Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] mwifiex: Fix possible buffer overflows in mwifiex_config_scan Date: Tue, 8 Dec 2020 23:09:51 +0800 Message-Id: <20201208150951.35866-1-ruc_zhangxiaohui@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: HdxpCgC30WdDl89fT5mvEA--.5983S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr47Ww13AF4xGw43XrW8Zwb_yoWkCwcEgw nYqFs7JrW5J3s2yFs09w4xu34ayr1kJFWfua17tayrGFWxtFZxGFnYvrs5Jry3CwnFvF93 XrsxA3y3Jan7ZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRR9YFtUUUUU== X-Originating-IP: [202.112.113.212] X-CM-SenderInfo: puxfs6pkdqw5xldrx3rl6rljoofrz/1tbiHgX0MFSIrfsp4gAAse Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Zhang Xiaohui mwifiex_config_scan() calls memcpy() without checking the destination size may trigger a buffer overflower, which a local user could use to cause denial of service or the execution of arbitrary code. Fix it by putting the length check before calling memcpy(). Signed-off-by: Zhang Xiaohui --- drivers/net/wireless/marvell/mwifiex/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index c2a685f63..34293fd80 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -931,7 +931,7 @@ mwifiex_config_scan(struct mwifiex_private *priv, wildcard_ssid_tlv->max_ssid_length = 0xfe; memcpy(wildcard_ssid_tlv->ssid, - user_scan_in->ssid_list[i].ssid, ssid_len); + user_scan_in->ssid_list[i].ssid, min_t(u32, ssid_len, 1)); tlv_pos += (sizeof(wildcard_ssid_tlv->header) + le16_to_cpu(wildcard_ssid_tlv->header.len));