From patchwork Wed Nov 1 19:23:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maya Erez X-Patchwork-Id: 10036937 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64FBA6032D for ; Wed, 1 Nov 2017 19:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B38D28521 for ; Wed, 1 Nov 2017 19:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 602C528AD2; Wed, 1 Nov 2017 19:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14AE1285D8 for ; Wed, 1 Nov 2017 19:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933242AbdKATXp (ORCPT ); Wed, 1 Nov 2017 15:23:45 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:64767 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933191AbdKATXk (ORCPT ); Wed, 1 Nov 2017 15:23:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1509564221; x=1541100221; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=++v2+mZ5JbFGV2SV3osKc2EIjqsf4q56K3Wc3HKgdC8=; b=HlJvp/NFePXLneAkobLF9Zf9sIopK/Lkk+YJY/9ZrtWJlv6RalV4HVV6 hLKT9cCy3UkWS9c3u05U9ReP/cDIcme/8/dGJpyXx+7cfqiXxoVyHNzBY CvpY/u8XHA84KHxAMkAhZ5gh8J8QyAbxhnx2ZB0Zegi/JSpHFeecxx1WO w=; Received: from ironmsg04-r-new.qualcomm.com (HELO Ironmsg04-R.qualcomm.com) ([10.53.140.108]) by alexa-out.qualcomm.com with ESMTP; 01 Nov 2017 12:23:40 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8702"; a="1524931165" X-MGA-submission: =?us-ascii?q?MDEM+ShJFdF9eaxUMS3Oubdj182uS6MC+WQ1+U?= =?us-ascii?q?pDXHX6Dipid4XRd5U8KPrqsey/l4wlr7XSxAXrGwvbC3GFXdeCXWiJBE?= =?us-ascii?q?qZzXMXg6S5UP08eKEfUtJ6sxFGt+aj3MwBsgbQkwvBagTmEmdKW3Kddw?= =?us-ascii?q?J6?= Received: from lx-merez1.mea.qualcomm.com ([10.18.173.103]) by Ironmsg04-R.qualcomm.com with ESMTP; 01 Nov 2017 12:23:39 -0700 From: Maya Erez To: Kalle Valo Cc: Lior David , linux-wireless@vger.kernel.org, wil6210@qca.qualcomm.com, Maya Erez Subject: [PATCH v2 08/12] wil6210: missing length check in wil_cfg80211_mgmt_tx Date: Wed, 1 Nov 2017 21:23:18 +0200 Message-Id: <1509564202-30078-9-git-send-email-qca_merez@qca.qualcomm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509564202-30078-1-git-send-email-qca_merez@qca.qualcomm.com> References: <1509564202-30078-1-git-send-email-qca_merez@qca.qualcomm.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lior David Add a length check in wil_cfg80211_mgmt_tx to detect unsigned integer overflow. Signed-off-by: Lior David Signed-off-by: Maya Erez --- drivers/net/wireless/ath/wil6210/cfg80211.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c index c3d3c0c..771a534 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -901,7 +901,7 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, u64 *cookie) { const u8 *buf = params->buf; - size_t len = params->len; + size_t len = params->len, total; struct wil6210_priv *wil = wiphy_to_wil(wiphy); int rc; bool tx_status = false; @@ -926,7 +926,11 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, if (len < sizeof(struct ieee80211_hdr_3addr)) return -EINVAL; - cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL); + total = sizeof(*cmd) + len; + if (total < len) + return -EINVAL; + + cmd = kmalloc(total, GFP_KERNEL); if (!cmd) { rc = -ENOMEM; goto out; @@ -936,7 +940,7 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, cmd->len = cpu_to_le16(len); memcpy(cmd->payload, buf, len); - rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len, + rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, total, WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000); if (rc == 0) tx_status = !evt.evt.status;