From patchwork Mon Jul 31 16:32:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maya Erez X-Patchwork-Id: 9872467 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 676FF60365 for ; Mon, 31 Jul 2017 16:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B6772856D for ; Mon, 31 Jul 2017 16:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A0322858B; Mon, 31 Jul 2017 16:33:06 +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 C842D2851E for ; Mon, 31 Jul 2017 16:33:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752558AbdGaQcm (ORCPT ); Mon, 31 Jul 2017 12:32:42 -0400 Received: from sabertooth01.qualcomm.com ([65.197.215.72]:32235 "EHLO sabertooth01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752546AbdGaQcl (ORCPT ); Mon, 31 Jul 2017 12:32:41 -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=1501518760; x=1533054760; h=cc:from:to:subject:date:message-id:in-reply-to: references; bh=HxdMHze1aQ3zBmffTkZPps9fOSRrnYyjroIxgAB6n68=; b=hfjt6vXhsrJoHIbDaZ9/ZMyV2PXG56dNo5BoQVh3VWZjTl/nuEevNPe1 qaKrHFTUqTw7b3JCvQy39gRGibMCExxa1m36gZzuldj4sSj85vXbEXtJL LaWVFA97Kn++hv5A3E44r9LXTAcKGUj3v3sJ1cE/zPY1dAWBca2npC91V E=; X-IronPort-AV: E=Sophos;i="5.41,304,1498546800"; d="scan'208";a="111885517" Received: from unknown (HELO ironmsg02-L.qualcomm.com) ([10.53.140.109]) by sabertooth01.qualcomm.com with ESMTP; 31 Jul 2017 09:32:38 -0700 Cc: Hamad Kadmany , linux-wireless@vger.kernel.org, wil6210@qca.qualcomm.com, Maya Erez , Lior David X-IronPort-AV: E=McAfee;i="5900,7806,8608"; a="974365059" X-MGA-submission: =?us-ascii?q?MDHBgtzO/JRdgiO3XrB0v6H357gZ/d+UDsajr4?= =?us-ascii?q?Hfv32vHhVDGHFVxlezxCPHW6HisXv+Rrsa9FcyeUcazipbSIh8YQc/mo?= =?us-ascii?q?J6y+H5MzhYbQnAJhn8fJmU540miBLIIhv2t7oRx1kgm3IwPnd+FgY+xm?= =?us-ascii?q?OE?= Received: from lx-merez1.mea.qualcomm.com ([10.18.173.103]) by ironmsg02-L.qualcomm.com with ESMTP; 31 Jul 2017 09:32:36 -0700 From: Maya Erez To: Kalle Valo Subject: [PATCH 01/10] wil6210: protect against invalid length of tx management frame Date: Mon, 31 Jul 2017 19:32:24 +0300 Message-Id: <1501518753-6339-2-git-send-email-qca_merez@qca.qualcomm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501518753-6339-1-git-send-email-qca_merez@qca.qualcomm.com> References: <1501518753-6339-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: Hamad Kadmany Validate buffer length has the minimum needed size when sending management frame to protect against possible buffer overrun. Signed-off-by: Hamad Kadmany Signed-off-by: Lior David Signed-off-by: Maya Erez --- drivers/net/wireless/ath/wil6210/cfg80211.c | 3 +++ drivers/net/wireless/ath/wil6210/debugfs.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c index 0b5383a..77af749 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -884,6 +884,9 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, wil_hex_dump_misc("mgmt tx frame ", DUMP_PREFIX_OFFSET, 16, 1, buf, len, true); + if (len < sizeof(struct ieee80211_hdr_3addr)) + return -EINVAL; + cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL); if (!cmd) { rc = -ENOMEM; diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index f82506d..a2b5d59 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -801,6 +801,9 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf, int rc; void *frame; + if (!len) + return -EINVAL; + frame = memdup_user(buf, len); if (IS_ERR(frame)) return PTR_ERR(frame);