Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3355874pxf; Mon, 15 Mar 2021 07:52:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziBW75vEPaw8dFUOfhBa83IqewpFTiJwxmRgtidvv+gocQl5jdJFYBFZuGsvz0yDbpaGYi X-Received: by 2002:a17:906:5597:: with SMTP id y23mr24334596ejp.165.1615819816862; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819816; cv=none; d=google.com; s=arc-20160816; b=tGpFJR/jXaCGq4gD+bBEt0W5aIHD3wYio+5M+JHTngsN/J96HcosN70kBoUGV55NHm P+LxRhEf5wiI7Jf1Bu9M+bhlP4vubOZoVQajz0uuQmWFke0R3MQpxyei/cWtO1VdLpKj lZGFIijr00766lS4RkUU7+fKw8kS5Ne5Q6vGkHp6SlhhbJ0fC51otvcY261gizKyitgg SWDGtHVotMlbpeHJevgqQly5PScpnPRF2pmsw7bhIZbxddepqWpU0fU9o4OTeASud+5j RdPDtPOgfv65LWbx++hGzel6tDYZqR/MmFvfGsKIVIdvcMsddqRO+CfSDrJnLh21xEdx 8YQw== 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=jkvgnb3o011oyngL+w3k/5hm0PMiz9h17AV9Jv3lrZE=; b=qiRtwPLtSjA/0ghKxQlgoYHlUCJH6f3vRK/AYEGwBv3cxdpmua6jx476Tg4LIMPE9Y v6NgW1v/Vl41BOBnXFFIDaMrZE8G1OjaBh9o6kGT1A5woL1C4EYLXwD06XIEJHLPAQwC oa2EVAlIKJ4VYqldnTUBsVn46TmwfASy3PJSoJ2j3UvoycWLYOQ2R+QFcmEUY5eSKZCp gcLjQzeDyWGvnV4XcPm+ohZIyhwLw7p/MrlKlmG0GuwXdWII5bqavr9zXj0E5yswRUQf XrCQ0h+FFjiychSM0w0NyBB6o+wHXOpLIQBgiX+IR95eAwm4z032IF9M31Zd42glAqwT zbXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gMNeHkpV; 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 b65si12072523edf.391.2021.03.15.07.49.53; Mon, 15 Mar 2021 07:50: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=gMNeHkpV; 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 S240535AbhCOOrv (ORCPT + 99 others); Mon, 15 Mar 2021 10:47:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233877AbhCOOCe (ORCPT ); Mon, 15 Mar 2021 10:02:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B917264E83; Mon, 15 Mar 2021 14:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816953; bh=IFfqQ8qPfWnqGiSXAud+IN7dXAdtEKUe1+FwHMdPJCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMNeHkpV2kunLcne9LTS5lcFcGgZA1S7vSSwbvTYi/wUi+Uxymv6v6wpnPK+Lhp08 6Iqr+NeUk4KhK9ktByD4rtlh5muUVZy+hvOAsB76X9eBtgNifBEsTP3DgLbtKpAO+i jmjGDC5oBgbyQOqFdgzLQfIzfNcSpCofHElEDUq0= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.11 225/306] staging: ks7010: prevent buffer overflow in ks_wlan_set_scan() Date: Mon, 15 Mar 2021 14:54:48 +0100 Message-Id: <20210315135515.223753558@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: Dan Carpenter commit e163b9823a0b08c3bb8dc4f5b4b5c221c24ec3e5 upstream. The user can specify a "req->essid_len" of up to 255 but if it's over IW_ESSID_MAX_SIZE (32) that can lead to memory corruption. Fixes: 13a9930d15b4 ("staging: ks7010: add driver from Nanonote extra-repository") Signed-off-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/YD4fS8+HmM/Qmrw6@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_d { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_scan_req *req = NULL; + int len; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; @@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_d if (wrqu->data.length == sizeof(struct iw_scan_req) && wrqu->data.flags & IW_SCAN_THIS_ESSID) { req = (struct iw_scan_req *)extra; - priv->scan_ssid_len = req->essid_len; - memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); + len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE); + priv->scan_ssid_len = len; + memcpy(priv->scan_ssid, req->essid, len); } else { priv->scan_ssid_len = 0; }