Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528610pxf; Mon, 15 Mar 2021 11:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgWLPXSrndQMwByP7/inddV3+FyHA5+m3R55p3eutd/KlnU9GWlunjfA6byNW1OXoDqImt X-Received: by 2002:aa7:db15:: with SMTP id t21mr31557621eds.145.1615833255640; Mon, 15 Mar 2021 11:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833255; cv=none; d=google.com; s=arc-20160816; b=yjqyMf4+Qv7HRIhxuGuhCr3SPT+tlF15MBQuDl4dLgEZdMLjiBFiOhkV5ZJv5cynxC 3nCEU1fSyDtU9T+uLhCeocS7RALmu8TR9iyGVF1FkJsu9nwEJSFlLlRlksUmFEPYwNVT JJ09DNsSBjtvPrqzxFVTKKOUTbpfws1/qvrbltaJBwMJVm/lSV5z3lOhPd3nnyYACPMv IuyXzKFiWKjQ3PzyNEU6t13iNzaBOr1ZWBW2c9D2c6laNegZeRSAEbw3LvI6El120KNF M7B0HYmBKn4JjNSj0wTucD4+z8y0c2/7EdezZpg8pAjc3thJVhrnqnfsLu1oLKpVOPgz 0p7w== 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=JqUx0+itmNdQfiMPnrk1B3yLN0rFqnePU0INYlf+FPs=; b=JRBZuu9oa9DAdATEASFZcoCb1DYM+dJPeKJHk7DRZZTAEJmNCaoaV7Fl1A114EvBgB v5WLMGD33dk0y5+9b9hW7ujsaHiH+6lKM+jAXFHn/hmwqPlmP5BFDOSuP8cW0xoq6mMc Bk7Gnsmx+lEBukDQ5NZOJQv99SUvF/qu0LA/zPcC1YgCTaIkFdj6pGSpKPJg3BiIhrMG 438089peeKxn25Cuhx6uEqwDxRe6vyZxG73ba5swzp70ktrgbTT/lQF/jBV7vyqVX1e7 ngx8QxgkM57JZysxpOpmAnwyMDjQa/8LKjn/1U6gMggEU9spInZFUVU60/pcBQbgf3Ed B5EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzaIqF2w; 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 de6si10954291ejc.467.2021.03.15.11.33.53; Mon, 15 Mar 2021 11:34:15 -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=gzaIqF2w; 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 S238145AbhCOOmX (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234208AbhCOODE (ORCPT ); Mon, 15 Mar 2021 10:03:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3516264EF8; Mon, 15 Mar 2021 14:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816984; bh=fnqaDvOIl3flW8dj93DMlB+IT7SBjVMZaIWlYPB2ZlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzaIqF2wyqOsi+Yq/gnmFh9qvh9cnmRyLlfW5nhJBxcTIiJcTrEAHfnJJDkMb9thW OGOGr32kvJtJa+ElYkv+ri0cZ8lJ1m4B1skIARwqkvU5WjV++JD6mo/KOaZQEw9PKi j4OQad/5mjDz6kPqssNC9bPzw0Wj+4+UREsb1a4I= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.10 228/290] staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data() Date: Mon, 15 Mar 2021 14:55:21 +0100 Message-Id: <20210315135549.685226320@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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_, _SSID_IE_, &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_, _SUPPORTEDRATES_IE_, &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_, _EXT_SUPPORTEDRATES_IE_, &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); }