Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1702679ybi; Wed, 17 Jul 2019 20:25:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDU0ViKbbTfnAU3o5nm2999sL5gRzBpDFlIhx6pkEtSBSNLI3UxkAUtACYVXf3f0vb0alx X-Received: by 2002:a63:5823:: with SMTP id m35mr45811681pgb.329.1563420302502; Wed, 17 Jul 2019 20:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563420302; cv=none; d=google.com; s=arc-20160816; b=Vgo6vHq/Wa3q+FRLSYAGjri8/dxAZR2eGOMEsmD8RXCuN5tx6H212grgeux6QsQRKL nD/uyxzMi0k0SEHULTW3DdHAB6xVEn8NknFlsvwN3c8osfoLSPyq0gL/rv5NKvVXt+IN GStdD5RU+yFjhdb6o154/UzygOREIKvU88s1zMqgYkJRpfH79iOISJURAPf1Bc8CwN+I pGAIcRvOhXKOM4Sw1WBiYVQAkW/OX00b5nVWD+9LzjwZDp6Np3s2GC/lTJvf/Oxu1TAf y8PRkg49gK54UjSVjLGQzcdwj9zUGrS++rJsU8fTAM+xVDVCWOJd3JzhliqXNkuBZ9En eA0A== 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=2wy1XcUvRxhMbtVG17AwCyJy0JJIKPJ4vnABLJemDnA=; b=OPal0yB+16R9RS14fcaHjAv2+1vXzSnEvEitoR5MO8sg6GXmlq6PZnDLKd2aBbW6oa rjZrBrrDCGYTr52elzZcx5lzbXP0lpKggqZ+Bbhwf6xLyYNvQHd5HwFBKPb1sfBQpDAP lqpApTY/EWkaY5eKRvxVReRVyawgM7UlMkSLqloA/NOhTGlVKmqAk3ZzKgoLdNSdejm+ AAPE2HQZ83icTiajKGTaRH6COPodlYc00zxjwB5l4R1YgehAXuLiNJjvkLP2YKSEuhnI DpxOcJdPRlsgGmL7pnsFhYpJgy3sqX5j8aXdACpXpWRyzRZv9HoioGQaSGeab9Tr0AXg 4RqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jinu2QMT; 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 r12si1183746pgm.473.2019.07.17.20.24.46; Wed, 17 Jul 2019 20:25:02 -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=Jinu2QMT; 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 S2390829AbfGRDIk (ORCPT + 99 others); Wed, 17 Jul 2019 23:08:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390266AbfGRDIj (ORCPT ); Wed, 17 Jul 2019 23:08:39 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 E946E2077C; Thu, 18 Jul 2019 03:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419318; bh=MM5i1/lwAKYQC92CSXJiFmuKGjT434DmFmldHqmDxbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jinu2QMT4lkK13WH1cgyMj2vgp8kPHYQp9junR5vetTvNCbqV+S3/Wmjrwx9MHolt brbVfc/bdMswkhrB01Q4jBoUVIInNxwqVlxXgXs6wsGSvD026AfB9yswmcoGt9Fvcn uchIaj3500OOP+SroR6D6VsO3j4QVp9LpVbHq7YM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, huangwen , Takashi Iwai , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 13/80] mwifiex: Fix possible buffer overflows at parsing bss descriptor Date: Thu, 18 Jul 2019 12:01:04 +0900 Message-Id: <20190718030059.856460093@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030058.615992480@linuxfoundation.org> References: <20190718030058.615992480@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 [ Upstream commit 13ec7f10b87f5fc04c4ccbd491c94c7980236a74 ] mwifiex_update_bss_desc_with_ie() calls memcpy() unconditionally in a couple places without checking the destination size. Since the source is given from user-space, this may trigger a heap buffer overflow. Fix it by putting the length check before performing memcpy(). This fix addresses CVE-2019-3846. Reported-by: huangwen Signed-off-by: Takashi Iwai Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/scan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index c9d41ed77fc7..c08a4574c396 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -1244,6 +1244,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, } switch (element_id) { case WLAN_EID_SSID: + if (element_len > IEEE80211_MAX_SSID_LEN) + return -EINVAL; bss_entry->ssid.ssid_len = element_len; memcpy(bss_entry->ssid.ssid, (current_ptr + 2), element_len); @@ -1253,6 +1255,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, break; case WLAN_EID_SUPP_RATES: + if (element_len > MWIFIEX_SUPPORTED_RATES) + return -EINVAL; memcpy(bss_entry->data_rates, current_ptr + 2, element_len); memcpy(bss_entry->supported_rates, current_ptr + 2, -- 2.20.1