Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3523248pxf; Mon, 15 Mar 2021 11:27:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK4+Z9A4ZHWTWqDVernpvlTVL/S0+mWKqz5bGEdDfWejzlgfkhALm2PqEUyANGwq3WIH8C X-Received: by 2002:a17:906:8308:: with SMTP id j8mr24528471ejx.339.1615832836837; Mon, 15 Mar 2021 11:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832836; cv=none; d=google.com; s=arc-20160816; b=GUCx5giBRFMLMmNdjLkhF8jrMDWyGR0HanEtB2RzuK4ToLB+ijRoY0rKDGWHLditgp iSCDFqXwZmde5VWItnRuZQl2C2tmjQcftzSe3Sske19aCu1j3Boi2xudy0774Jae42D4 y7GiH4taPAAFNvHBkdKToVd7a2EbOtL232pzIjIfYFP/xC5LrcvFtIra3cB9ETyb7eib dna3eIKNJOuF3gqfEwN+0WkICWPR6BLxZxAEX1GLqVfiirvHa4521zqhkseyJ/iNOuS6 uplnn3BN9Lez8ipvYBokphHmRsGKPTfpD9YqcbtTVFyHEMGYf9nVSNGjI8RgGmUzUf9j J+Jg== 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=4I0CK6+PH5ISY2ddm+Z8EYuVYwlrFIA9r7zv1WjXrRA=; b=AlAg+sriWJliybIyRJqxQXZN3I8Jjf0RB2DG78TdLkOWg8NC+DXwVEDvJCcCwBpdWR qNlmgc7W1/eNTBabUOtP8toQg64X84ui134EBl0ezYaZm1NeP34A5dy/WuR79/5VDwX9 rHNSqUazkqWTUHL5vD5SmMQDXiwzqQmSJpfLAQQisOSVCeab0WA0xTGvwZmupDXDyjcj VGM1dgjdG7cHBZ+QX6GnhYNWXQ7wApRHYEWQL+d9D658mo7MhpWfwRbS2YJ7uNcHQ4K/ Rso/tkFFvQzEWDorSW0UiXqFLdQQZJfR2MZwn7LpTFKfeHraIeGt0OBFLhx8H9OLUEY/ y6sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rN9X7eB/"; 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 b5si11371677edq.537.2021.03.15.11.26.50; Mon, 15 Mar 2021 11:27: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="rN9X7eB/"; 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 S238333AbhCOO0H (ORCPT + 99 others); Mon, 15 Mar 2021 10:26:07 -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 S233033AbhCOOAe (ORCPT ); Mon, 15 Mar 2021 10:00:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4FE9A64F0B; Mon, 15 Mar 2021 14:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816814; bh=rmXW1BrrexEFnDJF9MaWbYvftiMtUytwwrL7bvFJhVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rN9X7eB/8GgzBFeb/fadNqjkgky3S9uCojEW9ttJ4v/Fj6uJ3+AbRK++7jTIraNH7 6JcqyP2cnk5FRhWjUbyDMnr7FEbDlc1Iq5qd6+nsI4Brvqx882aYzajKlWEbYzUyHQ VZQFuso2SicdpHh13x5gjA9EMlxfk5DfU5yMeFNk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.4 127/168] staging: rtl8192u: fix ->ssid overflow in r8192_wx_set_scan() Date: Mon, 15 Mar 2021 14:55:59 +0100 Message-Id: <20210315135554.522930342@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: Dan Carpenter commit 87107518d7a93fec6cdb2559588862afeee800fb upstream. We need to cap len at IW_ESSID_MAX_SIZE (32) to avoid memory corruption. This can be controlled by the user via the ioctl. Fixes: 5f53d8ca3d5d ("Staging: add rtl8192SU wireless usb driver") Signed-off-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/YEHoAWMOSZBUw91F@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_wx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -333,8 +333,10 @@ static int r8192_wx_set_scan(struct net_ 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); } }