From patchwork Wed Aug 2 21:00:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maya Erez X-Patchwork-Id: 9877753 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 1ED6A60360 for ; Wed, 2 Aug 2017 21:01:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FFB72882F for ; Wed, 2 Aug 2017 21:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04E0F28831; Wed, 2 Aug 2017 21:01:03 +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 A7CA42882F for ; Wed, 2 Aug 2017 21:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbdHBVBA (ORCPT ); Wed, 2 Aug 2017 17:01:00 -0400 Received: from sabertooth01.qualcomm.com ([65.197.215.72]:35554 "EHLO sabertooth01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173AbdHBVA7 (ORCPT ); Wed, 2 Aug 2017 17:00:59 -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=1501707659; x=1533243659; h=cc:from:to:subject:date:message-id:in-reply-to: references; bh=HxdMHze1aQ3zBmffTkZPps9fOSRrnYyjroIxgAB6n68=; b=g5BrHtKSuThA+WYPdapgd/Bg4j+JrFCa2KmsPPtpmrkrw+dyrDQEBiwz wtwWc/pYjV6pmjpnVMUbv2geBogsrHJKTWnFIZ94zQaqEKvcx7eTU6d9H 6bsood/ClIwaBFK8mK2BGAsr2ElWTh8RdIsBxBrbwFKPxwSgKgouebCoK I=; X-IronPort-AV: E=Sophos;i="5.41,313,1498546800"; d="scan'208";a="111952939" Received: from unknown (HELO ironmsg02-R.qualcomm.com) ([10.53.140.106]) by sabertooth01.qualcomm.com with ESMTP; 02 Aug 2017 14:00:58 -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,8610"; a="1009681443" X-MGA-submission: =?us-ascii?q?MDHeA1fvGOFZlTeObmn9+ZFqcA6RHHBPvHu1xx?= =?us-ascii?q?fUu17WhdvVAAe9BZIhWYHNX+BQ57tRqwLOekBYMbzAvADCXtrMN1MwQu?= =?us-ascii?q?k8mXxVTZRq77CjVzeAU4YKYV3bp7LAmJ3ApCnGo1BRbTlU4BYbyTFmbM?= =?us-ascii?q?0i?= Received: from lx-merez1.mea.qualcomm.com ([10.18.173.103]) by ironmsg02-R.qualcomm.com with ESMTP; 02 Aug 2017 14:00:56 -0700 From: Maya Erez To: Kalle Valo Subject: [PATCH v2 1/9] wil6210: protect against invalid length of tx management frame Date: Thu, 3 Aug 2017 00:00:41 +0300 Message-Id: <1501707649-9665-2-git-send-email-qca_merez@qca.qualcomm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501707649-9665-1-git-send-email-qca_merez@qca.qualcomm.com> References: <1501707649-9665-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);