Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3354369pxf; Mon, 15 Mar 2021 07:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypM44d67ZAo36+Q5fnjJwebEH9cSPgMV+aart+exWupzbt1j9BQ7be87mMj8mktfN16ZMz X-Received: by 2002:a05:6402:170f:: with SMTP id y15mr30475064edu.127.1615819816803; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819816; cv=none; d=google.com; s=arc-20160816; b=liF8QQ4mOaOyP/BRm9Hd7mmEz7suRTNZxvc9jUiU0/WDvNff5qy/WNxxiyJERKFt1B GTGYbgi5IXGtjH5VbWbuKQMMQFvf4iNNrVF5XXAPzsmoBEcK6HT6eVFOPgoq041AnqgK UTWIBfpWU+LCZF1alfdWsWpOaC1ZdCzxU7BJ+cMWcIf5N4xePp01q2FClLItWQJ+2Yz7 ofTLKnzem2y28auCEb2my8i9OmXwJG7OxMcm4qpghGpTD5iywUU4SNj0FQ9RWyrSGslG RRdfXWxgZOZGzBXmIpXbzCtpARgXWY1ULO0iX7NprB5z9v4eJMDffFXmu83DB4Ay2WTx qJKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zixjeNtXgnkRFg0CYFF+k6yuF5/nYEqmxcGTQLjLcww=; b=OqV+B6x5mIkKrfCfdnEQcHc2IiufQHXmgQDCK/6XLFf0x/4WOL9xIrp1m3Na/oBy4o g+KjBTCbu7VwFR2sfct+ULbGQv/vHLkyy7zHqYFNe8nAygYq09GlNTW18SFa4SN9kbpI t7d29ttaW1n0ptGFhJLU5TSVJxu64lvBaKUR87TWXIte+m4Y7BriqSuWDw2Jsuhql421 lfEUFxczSbiaLI6PJgvAhAczCQ83EwvQPCXFSi7lzjVmQ09JwVsepEVuFhkJECe6cVe2 EaDBcVLwMJptegpfKlu4m+NgaUOSXThBpeLqQYQp/3+xCRk6koCR7ztr5lgK9AnaB7zu nSzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UwAaN6A/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si11824722eja.212.2021.03.15.07.49.53; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UwAaN6A/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240396AbhCOOro (ORCPT + 99 others); Mon, 15 Mar 2021 10:47:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:49126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233864AbhCOOCc (ORCPT ); Mon, 15 Mar 2021 10:02:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7056664EED; Mon, 15 Mar 2021 14:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816952; bh=3/mW/DhoCqLKSjF5kQ71BZddQuaKTbNofzsLT74kdAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwAaN6A/Cli3YF3ZgoYvxdKxyOEieLAz7FGzOQhF0RvhmCyY/oDg1coDuro7xJgpG I2YvGOSiUdl3vuS6jasDByxcUVEPJqzF8wkc1he1lNCrUeZA+wVj681JSN7xrh67E5 fWrHoEEr4zNvpGlrgIjqWBDEO3eJNDpQfklNuiUQ= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.11 224/306] staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data() Date: Mon, 15 Mar 2021 14:54:47 +0100 Message-Id: <20210315135515.192746692@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Dan Carpenter commit d4ac640322b06095128a5c45ba4a1e80929fe7f3 upstream. The "ie_len" is a value in the 1-255 range that comes from the user. We have to cap it to ensure that it's not too large or it could lead to memory corruption. Fixes: 9a7fe54ddc3a ("staging: r8188eu: Add source files for new driver - part 1") Signed-off-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/YEHyQCrFZKTXyT7J@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -791,6 +791,7 @@ int rtw_check_beacon_data(struct adapter p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) { + ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid)); memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(pbss_network->ssid.ssid, p + 2, ie_len); pbss_network->ssid.ssid_length = ie_len; @@ -811,6 +812,7 @@ int rtw_check_beacon_data(struct adapter p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p) { + ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX); memcpy(supportRate, p + 2, ie_len); supportRateNum = ie_len; } @@ -819,6 +821,8 @@ int rtw_check_beacon_data(struct adapter p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p) { + ie_len = min_t(int, ie_len, + NDIS_802_11_LENGTH_RATES_EX - supportRateNum); memcpy(supportRate + supportRateNum, p + 2, ie_len); supportRateNum += ie_len; } @@ -934,6 +938,7 @@ int rtw_check_beacon_data(struct adapter pht_cap->mcs.rx_mask[0] = 0xff; pht_cap->mcs.rx_mask[1] = 0x0; + ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap)); memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); }