Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3294990pxf; Mon, 5 Apr 2021 08:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySUo9gSYWjxwMPMZIiZaFCTA0U8w9S0pR8bpAYxhJES4wXf0pwH29QDpBCSrFfPA9IZxND X-Received: by 2002:a05:6638:1648:: with SMTP id a8mr23967023jat.25.1617636001109; Mon, 05 Apr 2021 08:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617636001; cv=none; d=google.com; s=arc-20160816; b=g5TJRZ2IVVAsub9A9Ygv+N6qo5E12DgqTxsHI5AVbmjF00FavdV9HKsQe4OiyUKqGs 1GfhS3KMlW3hosoPY70XFfapX/r3UKh7utjfQS/53zb3YSknSCpz4GjjgB8BlJRepFWM 5W5/m95mQn1BDnmIaRFxt93FO1H0CLiVL9cqADytKrHpIxlKWeGw9PLSYwVlhzAnVkR7 wLYON8zBHfUuPpc6AUAlyUl/c2ZYMCYumm2WR2qcgWlp3rF1UMYuuRogWX9+sKUgDZwM xS6y607COGP9O5jvnYkrUqtt90VAuk5//DG5tnQg/Z7sxkDKeIYmZ24o8jMTh3y0gbda wRUQ== 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=n9wMaqtERFlSOOUGpbqdY/w31X4shgRb3wTp3xmRgEI=; b=bIHJKMOOgkY46OMRcYHcJKTPLPSAfLRBxs2lBqrDUG+gOOXEeYti+O0FqCd7qhfNDa VZ1eFG+dPUc6e8DHjwxgri43QhoGZjOSAc8tDCVp4Uk4CGRlEgsycG705WcQOhAAuLTP wg2SMqTDKYYaMsmw6XsYWuf318BXTd8HVV/2sZ3fErj2E7RtQW2uJ9djnRkW8JG/gPLe Kro/s6AONxIwHIMbSlGx/3cpJfeGk+x3/GIr0pJpi1iHY2Wti//0TSlXszZQDdenCVD8 HCdqyYWcwkP90uxT9XOaFmYBaK6GOBqtbGaJq3+2xpyaqVVgVDWvRQXPkQiHz3InMqCn d9Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkj99TnX; 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 m35si15327984jav.30.2021.04.05.08.19.48; Mon, 05 Apr 2021 08:20:01 -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=pkj99TnX; 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 S238359AbhDEJHd (ORCPT + 99 others); Mon, 5 Apr 2021 05:07:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:49776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238679AbhDEJFi (ORCPT ); Mon, 5 Apr 2021 05:05:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B002613A4; Mon, 5 Apr 2021 09:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617613532; bh=1FlLlzjcLm0GeT7D8m4KQAXu/GrkAdfaWvVzN3j0/p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkj99TnXwM77ey9l3CkvUr31ZC+lC8LUZFtDDljVO8KZDa3ALUS87QtYe61WFF7U6 tYVJTDJgwHPpSmY8key68CAT7IAAfVUpAPqr9UYaaKOhmH3jOVge1sj/Q+BZNWrg37 uut1YnpVHn6uwwxpVg1qxAKIFsQ5ljAoQ3vfcmXo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atul Gopinathan Subject: [PATCH 5.4 72/74] staging: rtl8192e: Fix incorrect source in memcpy() Date: Mon, 5 Apr 2021 10:54:36 +0200 Message-Id: <20210405085027.087688941@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085024.703004126@linuxfoundation.org> References: <20210405085024.703004126@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: Atul Gopinathan commit 72ad25fbbb78930f892b191637359ab5b94b3190 upstream. The variable "info_element" is of the following type: struct rtllib_info_element *info_element defined in drivers/staging/rtl8192e/rtllib.h: struct rtllib_info_element { u8 id; u8 len; u8 data[]; } __packed; The "len" field defines the size of the "data[]" array. The code is supposed to check if "info_element->len" is greater than 4 and later equal to 6. If this is satisfied then, the last two bytes (the 4th and 5th element of u8 "data[]" array) are copied into "network->CcxRmState". Right now the code uses "memcpy()" with the source as "&info_element[4]" which would copy in wrong and unintended information. The struct "rtllib_info_element" has a size of 2 bytes for "id" and "len", therefore indexing will be done in interval of 2 bytes. So, "info_element[4]" would point to data which is beyond the memory allocated for this pointer (that is, at x+8, while "info_element" has been allocated only from x to x+7 (2 + 6 => 8 bytes)). This patch rectifies this error by using "&info_element->data[4]" which correctly copies the last two bytes of "data[]". NOTE: The faulty line of code came from the following commit: commit ecdfa44610fa ("Staging: add Realtek 8192 PCI wireless driver") The above commit created the file `rtl8192e/ieee80211/ieee80211_rx.c` which had the faulty line of code. This file has been deleted (or possibly renamed) with the contents copied in to a new file `rtl8192e/rtllib_rx.c` along with additional code in the commit 94a799425eee (tagged in Fixes). Fixes: 94a799425eee ("From: wlanfae [PATCH 1/8] rtl8192e: Import new version of driver from realtek") Cc: stable@vger.kernel.org Signed-off-by: Atul Gopinathan Link: https://lore.kernel.org/r/20210323113413.29179-1-atulgopinathan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1968,7 +1968,7 @@ static void rtllib_parse_mife_generic(st info_element->data[2] == 0x96 && info_element->data[3] == 0x01) { if (info_element->len == 6) { - memcpy(network->CcxRmState, &info_element[4], 2); + memcpy(network->CcxRmState, &info_element->data[4], 2); if (network->CcxRmState[0] != 0) network->bCcxRmEnable = true; else