Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3355658pxf; Mon, 15 Mar 2021 07:52:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxag0UvN++66Pz2QnY2c0xkx2UwHGDPhSArCUbZ6QFJyLOITVK6FMDyAAJgc/iuRH89B0/K X-Received: by 2002:a05:6402:42d1:: with SMTP id i17mr9002520edc.131.1615819817174; Mon, 15 Mar 2021 07:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819817; cv=none; d=google.com; s=arc-20160816; b=n1zjZbxEQ8lgw7bsnI6GXGcEDMKI0Ck+EtttHLk5Ytf3nPu6EuHnhMHj4yet1G+2WS fJ1tLCGZThujrELgyW5/4bHXi/mPyDezQ5X1VDmUUmI9h/xAeBK6l2/HrbDXebrIoiCf nBA9H4K2mIgjwiDjtSjXFl3gPIV7NuZxLZhTFYKEwd3IpQNRZ5HwMpD+aaLaTh0knsjs mGZV/cq/ol1CaAxfMHQ334Us7ohyVy/J+5TOWfk0pTCtu8/OH2gzo3uk8KshpzXvA3up yHRT0npg7yqa7TYj1owYuQirIEZNjH35TVFibZfVIETzaruQPVMsvW77kx81NnsFYvD4 3QVg== 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=Y4dFr3xka2Vmyau1Bv+9dV6pL/bk9VeJPPE7aM9rWT+2183mcBVYAYSsriWK/Fa0ta 5nfyYyqLZ33r1tPh+1yljyQkJfjbfIM/C5OiygNbrozSlCmjcdhJJOMU1+EbxNHWgKJ+ OLEm1gvnx++djNavXmxLuR6B4ub/Ssu+UN/8pPVVa3mHOIM9JM9rOt9RBXb8HFhSLQRP zgvRxWMB31CDnXBw+Kz7CgrJ3x+9jeVM3z7CJazE20bFJDEgdKipRPgnvnipd1v9E6w7 wsRx5CybyfGbAT4v2ykZImdgSgRO/moteQzecVcuK39gieqm+a4bWbOCid5AJIiafs+J 5G1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ew6Hh00W; 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 o26si10891644eja.611.2021.03.15.07.49.54; Mon, 15 Mar 2021 07:50:17 -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=Ew6Hh00W; 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 S240604AbhCOOry (ORCPT + 99 others); Mon, 15 Mar 2021 10:47:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:49172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233913AbhCOOCg (ORCPT ); Mon, 15 Mar 2021 10:02:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B79064EED; Mon, 15 Mar 2021 14:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816956; bh=YbbD2OM49azgxz1waoAEtRW/HfYSxogBZ1pRKo4eEYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ew6Hh00WkJiw1BeMr0y9EJy8s2M64NveyWq8f3ZnH9BnrD+hbWu30BJj1AG/yTMoK 9H9UYbURDboFZdmhfMOkexNRtfCttTmdlOrnL2YltdweFLI+eIcOk8WZk1+/FyolbP 8/z3JPHvXADgWQhy3dP3+S6VNo1Ei6fAMkIBZpAY= 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.11 227/306] staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan Date: Mon, 15 Mar 2021 14:54:50 +0100 Message-Id: <20210315135515.294944748@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: 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); } }