Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528617pxf; Mon, 15 Mar 2021 11:34:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuOFSTHLf3EQs6f2e4YtNXipnfl++itSKwFgwS2DDJ4DHDNJ6f32745WZBGBxicUIcTN2a X-Received: by 2002:a17:906:58c9:: with SMTP id e9mr24413496ejs.26.1615833256072; Mon, 15 Mar 2021 11:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833256; cv=none; d=google.com; s=arc-20160816; b=UOa8rZXctvKADjVsmzrRGh/hXJn262tHoI8k91NbnWEHG/IWL+umc7lu3DtT/D7opA mSWn4XH11eaPqz0iLthZw3ICcj2AB6YFa9Y55fec7vzpmEpks3VehyF5ExavR4Agf2x3 YFcg5Ea5Jgo6Sp3ag+9tBeBK+hMEA9HsSUrXJhVzunErCXll1gO2oFGHja/Ey8bFGl85 /aEc+GTERdYqfVDE0hRy19x2Ch7sO18AAcGcgnHF2Pjxi4YXEGYMeHIsCOEav3r7O2NH qfkmPKZE0y4HDBjlpimQN1saKXex86edaDFx3ERbYaHqROuJXxGafdQnMAXoNJkGmgNs Y5XQ== 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=LQ8naUHUdIknrhFMDrTjt1q/mI3hYnK+pG2c0/zQAgEebpzPudGOozKP10kwTJhRkw 3c5ABNk5G+r/3hZ7cylyu8uNEcjnSXRGJuAKbz+FMJJ/MZQyF28F3HUc9AvEBleHX1cP xJhVqcXwQ+/Cuk/hRf+ysV4VkJNg+4kyhivhDWouTlk5Th+GnBeej8+QtLpIhZd6whCI lofdHKxQDUw6tv8QnLSx0ajSiWAvFqt7z1ikRCnaC/XgP1p/LtUFxMlkZBCiJjHU3o3j 1kLvV97a5laYxG/xIAk8eRDmBpLQ9PgpnIrk7A9ucsK6EnuBC6UQSd4D0xRVVKmvOMvX bhgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iJBQrD1r; 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 x10si11639228ejs.610.2021.03.15.11.33.53; Mon, 15 Mar 2021 11:34: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=iJBQrD1r; 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 S238341AbhCOOmc (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234259AbhCOODI (ORCPT ); Mon, 15 Mar 2021 10:03:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 142CF64EF9; Mon, 15 Mar 2021 14:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816988; bh=YbbD2OM49azgxz1waoAEtRW/HfYSxogBZ1pRKo4eEYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iJBQrD1r1uEqm5vPil4AU8IXP1NSxbXv0ccDl7iRxKDp2MsvqJiEQVsaykn2CtLZ2 9H/q0E5yWaj0Oe4487YjJ/GY9XSxtYJWMqpuFzHukOU4CYXoandgGiIjV+GFRVJHtQ VMCgAwIFmQ3/itVaJbfwDRA4m1TJvZicL015lJ0E= 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.10 231/290] staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan Date: Mon, 15 Mar 2021 14:55:24 +0100 Message-Id: <20210315135549.793415394@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: 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); } }