Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3524210pxf; Mon, 15 Mar 2021 11:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/HMj5AxeedbcYUPNbuKp2GY5Bp1y+xAg2mPH7vyEptTxcJ+PlwKO7zP2qJr55UVdmFOmF X-Received: by 2002:a17:906:948d:: with SMTP id t13mr24385678ejx.402.1615832903293; Mon, 15 Mar 2021 11:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832903; cv=none; d=google.com; s=arc-20160816; b=EmbpTedR820TLyvroSg3MHrT/RpXcAJDmAC6y/nVNQsxVJCGKUQDyWvRR3AaF+KXAc JosyMsxHrcQwzY18UT9tqBTSDt+NRBugy377UU/9+YDdVRqISZsJmBJey0nrgJQae23k wKuTBe8bh+zeF3i1ZSPWOk1pTMfmGIeUO8hwKyNNwkVywnNsZ95X/dNMD/0KnlHFxQCk Dq04/WZBWqnncQjwasFyjtlhIYK1YSWSvnWVnu04+boMOWZaIRcS/dIzwV7nD42bju7Q /QsYlOxay1eWagP1XhuFGiWEA+8SvB7463VbcWAr8HzMuxWboarxlHqxrrSkGD+VFaN0 DFhA== 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=naojXK2kba28VxS8CByq9WWqkVy5RLEp634oYs1O8bM=; b=GKRnBehMe9IOUSueT+ru7PZ3tV8OFX9MKlyrS89zfACFL1Z7mqG3MuiNiGeTiDuLH2 NlZC3ujzcJqhC//jg86fkd1lk+Hohe5iVcXAcVJcG6xslFEUHvTKxIuoEkZMjYQVo4rw O9WILjsNC4bNaZuBf4c+hPp5hq8tpvKSnWUaZ2wFByAmw38kcj4F2KpZfqceWwuK86zq cqDsVVAWT6YW/+cHicTnNKBDRTKq6E6OBNLK5sX18gv4US/xXRT6c5kFPpXJERb8/OwC PvqmsvpvuBja5wKNOWMG3bS4cKafxqjbgejfPLUrPo09rUR8cc9t2wTMovx4axmkYnNG 7cIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XhGYaesV; 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 u9si11645803ejx.635.2021.03.15.11.27.54; Mon, 15 Mar 2021 11:28:23 -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=XhGYaesV; 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 S231205AbhCOO2K (ORCPT + 99 others); Mon, 15 Mar 2021 10:28:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233081AbhCOOAh (ORCPT ); Mon, 15 Mar 2021 10:00:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED61064F52; Mon, 15 Mar 2021 14:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816821; bh=YbbD2OM49azgxz1waoAEtRW/HfYSxogBZ1pRKo4eEYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XhGYaesVCZhvvvt6mF6u6J6zjnEbEKxQHMyl1bfAQct1J4z87d5+2jGpv13qt7TfD Lmco5w5G4Rb3iub6fTPcgtZfotoZCB93166V/7IS69+Q6f2NBGD0A/PUyWvFPved9h nkrJL0A46sZL5YodmCuxF9RzChLWLKUb4rfUSQ+E= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Lee Gibson Subject: [PATCH 5.4 133/168] staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan Date: Mon, 15 Mar 2021 14:56:05 +0100 Message-Id: <20210315135554.714940336@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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: Lee Gibson commit 8687bf9ef9551bcf93897e33364d121667b1aadf upstream. Function _rtl92e_wx_set_scan calls memcpy without checking the length. A user could control that length and trigger a buffer overflow. Fix by checking the length is within the maximum allowed size. Reviewed-by: Dan Carpenter Signed-off-by: Lee Gibson Cc: stable Link: https://lore.kernel.org/r/20210226145157.424065-1-leegib@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -406,9 +406,10 @@ static int _rtl92e_wx_set_scan(struct ne struct iw_scan_req *req = (struct iw_scan_req *)b; if (req->essid_len) { - ieee->current_network.ssid_len = req->essid_len; - memcpy(ieee->current_network.ssid, req->essid, - req->essid_len); + int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE); + + ieee->current_network.ssid_len = len; + memcpy(ieee->current_network.ssid, req->essid, len); } }