Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp849272ybi; Fri, 12 Jul 2019 05:40:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzd6lpj8cZsce7NOlRe4Sl1g9oB6+x8XGc+0ndK4akrA8uvEBGjhXYQ9y0G6R6UN+NdbFLd X-Received: by 2002:a17:902:28:: with SMTP id 37mr10470128pla.188.1562935229076; Fri, 12 Jul 2019 05:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935229; cv=none; d=google.com; s=arc-20160816; b=Aqb7nXrnbvJycQeTSMw28gldEq3c0ySQc4psTOKGg8/iMXvuO96Zs8sMbNmipxpvGf OHmCdtRNPDi1OvybDeWJ9/sxNwhOqCm1kJfQXB/EK5ntT85hzmggB+tfFIAeRM0dWW9M UTTBTQJMKUXvfZZKeDxIWkZPtEj6H07fSVc+Hl0anUptoT8BBZT6YgHQ9nUuuDH9fxLA udcV+uc58N2hXPGfeXBgv0UeMy2dZtXyzEkAj6yMf0kL1dwyviEetV0n8SnfvFnaReaK ag1/hxlodqBuo+vJ54uGh1pU+VBixmb/fAtQ6ooHEIRIzC5EX935VzL6dGE/syph36gF 4tgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mBPk4O2skmxfVfM6rcATDK87SqkZRq7C4Uf3ICwREn4=; b=Wy0B1pRwz5oJDWoqiFNibdGRGmBYJwntZvmChBi1NRgmtzFpl3oupBoZEwMHz1nNJB +DIixQcVQsIsNQ/GEI2DxYC9iSY/brRgpC2kZJS7Zo31U2HNPjDSD3U2XUlulNkkU+PC CA1qM6UGmwMvUbBfFpTWYlz+XTPxz7F1TiJI70bR5t8HVc2N3p4dTLRmuszkmaXTIvP5 KyOdytimaDUT7lOJ1xWHNLw4snOvlXeKF9Ft2z+H4E0bW5cY5EqYowLS2JvIdXHpuTYu I4FGGZJpPL+uWY+/NLbu5PIORqFab7INOVl+qasH5bGkt7XZTFLCfG3wIE6Z8FfQPolb 4H/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YhXOtz2f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z25si7861879pgk.415.2019.07.12.05.40.13; Fri, 12 Jul 2019 05:40:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YhXOtz2f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728196AbfGLM36 (ORCPT + 99 others); Fri, 12 Jul 2019 08:29:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728737AbfGLM34 (ORCPT ); Fri, 12 Jul 2019 08:29:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43C3E21019; Fri, 12 Jul 2019 12:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934595; bh=RVgPEGVOeNx+ij6xhozVkER82F9/IjUOHeJY0SL9jbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhXOtz2fkhWIcdW9b3FUibUV9kmVVpad9QNrXhtGodD1j6K47fXHMUPsgkvxFyLCh qRDlX5CmHGVkPa3GtnxmMxdwvACs3ZNlHvyRGL9yuAaSOTedOOkdBezc+3SQfg3t/T W2F+LVu/CoN26Ee4MHbIoew9qICvpnbXcF4nCNRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Kalle Valo Subject: [PATCH 5.1 106/138] mwifiex: Abort at too short BSS descriptor element Date: Fri, 12 Jul 2019 14:19:30 +0200 Message-Id: <20190712121632.831241159@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit 685c9b7750bfacd6fc1db50d86579980593b7869 upstream. Currently mwifiex_update_bss_desc_with_ie() implicitly assumes that the source descriptor entries contain the enough size for each type and performs copying without checking the source size. This may lead to read over boundary. Fix this by putting the source size check in appropriate places. Signed-off-by: Takashi Iwai Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/marvell/mwifiex/scan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -1269,6 +1269,8 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_FH_PARAMS: + if (element_len + 2 < sizeof(*fh_param_set)) + return -EINVAL; fh_param_set = (struct ieee_types_fh_param_set *) current_ptr; memcpy(&bss_entry->phy_param_set.fh_param_set, @@ -1277,6 +1279,8 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_DS_PARAMS: + if (element_len + 2 < sizeof(*ds_param_set)) + return -EINVAL; ds_param_set = (struct ieee_types_ds_param_set *) current_ptr; @@ -1288,6 +1292,8 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_CF_PARAMS: + if (element_len + 2 < sizeof(*cf_param_set)) + return -EINVAL; cf_param_set = (struct ieee_types_cf_param_set *) current_ptr; memcpy(&bss_entry->ss_param_set.cf_param_set, @@ -1296,6 +1302,8 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_IBSS_PARAMS: + if (element_len + 2 < sizeof(*ibss_param_set)) + return -EINVAL; ibss_param_set = (struct ieee_types_ibss_param_set *) current_ptr; @@ -1305,10 +1313,14 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_ERP_INFO: + if (!element_len) + return -EINVAL; bss_entry->erp_flags = *(current_ptr + 2); break; case WLAN_EID_PWR_CONSTRAINT: + if (!element_len) + return -EINVAL; bss_entry->local_constraint = *(current_ptr + 2); bss_entry->sensed_11h = true; break; @@ -1349,6 +1361,9 @@ int mwifiex_update_bss_desc_with_ie(stru break; case WLAN_EID_VENDOR_SPECIFIC: + if (element_len + 2 < sizeof(vendor_ie->vend_hdr)) + return -EINVAL; + vendor_ie = (struct ieee_types_vendor_specific *) current_ptr;