Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526046pxf; Mon, 15 Mar 2021 11:30:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSgriKPWVIfUGkHtuOGAWuIniuFLNxXF76DsKIFC8vs7B8heFOId4/ehka7mBTBTpuviNT X-Received: by 2002:a05:6402:b70:: with SMTP id cb16mr31593391edb.11.1615833050156; Mon, 15 Mar 2021 11:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833050; cv=none; d=google.com; s=arc-20160816; b=WPLOvxOMDv26aHaquMd7GlP5FXtXqmJY0y75yT+O91Fid+ldGGjo1pU80KK3mFX+sr uQuCGIilT4pq7yPILqvIbiee4P0Hg3hVNpaZLHtjypvLhlZ1FAxZLmE9X6Lojhlh1BNv Ez1taHKXEV7mGf6QnUEuzMGvGUSyDeWaFlwp8CU40KQpijrrEWDgCbbKrI3NMzE0onom 2YlCIaHden1zyMrlCmitbbiX2S6ObR2A3uN3GIK7XqPNl+f7k2zExx2XKZ2UnCziEpnJ fs7fvY5w+iKvNw2vXk0pj0haG1LiMWebZFQdrizSL4gGxkw1nA+ec3D163APICAyeN2s 4r7A== 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=/a8rsebR7p+uqhLra59Ho8Y4/AEdnCDyd5XuCs6cy+c=; b=ie7FN10LgD5YWp9n5fFFN541fSQMvAxoEOsnQUu9visrc2PFWOivUmCpY/lbPcZ5wm FuP4MExychMTn0SAAp29rgPriXsFKAgEhgD89JeUxZFWjQ6YEVAO1Yhowok7EpLTlP41 e2W+Zay9NM5ccCEvoUwr7upONc+95ezOlXXGPTrClHMGOvE73NIAT4OuWQiDK/J5qW+i ZFEcjmcVf0kXPZa+1krMP0aFWuGCiXvSZYei8S7/Wgnt0u63xv3R7LIoCmCu64e4Codq GlGHJhwAVf+GCeE7Vb32ZwwW+rssHBOiyjJNXajeHWusvhK4y7DRoBd5l0pZw6H6bdKm 0wZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=plqJIzaR; 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 k2si11248893ejr.529.2021.03.15.11.30.27; Mon, 15 Mar 2021 11:30:50 -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=plqJIzaR; 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 S239999AbhCOOdW (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233148AbhCOOAv (ORCPT ); Mon, 15 Mar 2021 10:00:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24AB064F8D; Mon, 15 Mar 2021 14:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816828; bh=YepXQey3VhzdjKuyvShC6OU940m+12UNp0NOjewn6GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plqJIzaR3A+lB0Yf2BjsHMKmpMbPd9YnEoEq+jxluQt595xAp5H7ff8y8aDtjUZ0b FfGQZDcpUTxaLmwBIZ/kE4IVM99PaIwBfz4hFOb7Cmebfpn4sl73MF+9hsDdjItpDX Zb8qZs/sE3FMGS2fQtzTuY17SMyJEp0Au2N1+3HQ= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Lee Gibson Subject: [PATCH 4.19 095/120] staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan Date: Mon, 15 Mar 2021 14:57:26 +0100 Message-Id: <20210315135723.086563394@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 @@ -415,9 +415,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); } }