Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522746pxf; Mon, 15 Mar 2021 11:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykeyZxG7mmg0WYY91N11a7yaIc2rP0EvcplbOKlZz7Tn+V+STnbZ3KVIPkC9IRcksbrR92 X-Received: by 2002:a17:906:c099:: with SMTP id f25mr25692723ejz.141.1615832793845; Mon, 15 Mar 2021 11:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832793; cv=none; d=google.com; s=arc-20160816; b=A8gOB3qyQx5QllSaBvVLfhMW5LpivLIyqMhj+ijdehHC8+WPlfIXaC4O+JBb8PJqTq iS9onZH42bFNLClPYJxog5i5DSnC00U5D2h1HsHWLi/OSf0GR2ztsAlv+Mi++dWPhZL/ RPjH8AMoEqfzs6w2UsUG+GIJiiQ83Y5j2/0xh92D8FwriNAAEJFxtaMsc1IXl1a+MsIz Sz2msZ06pVuAF6a/ona6Q8Dv8uyrUEJnRQiUVBykL34hk6HCqUhsvZFuEn/RKFqRCJQw jbRnJW3WpPbU5oIxkXEh8sVFk517o1uCrq2uXxTYJqhWKFgEL/rMjILF+3oGc012Q8KR e1Ng== 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=cvf3aNC+N6a/KEeVVCdneX96DDCcALHnhtCZAfNnyCHv97AkOD6laMt2vk8ZSkmu1o EF4hr9vqxBXytJa8l7cNtVkXQzJrej6VN2vCzdNeuF+tfXqWRmXm4QWvyqFS7AZXaXmD N+Cn5yWv3TmpXW5DnkOXB/rv5/42pcPa12j2zTuOrgtodUYnM5/U6Guc2LR+9I9gjkPa UWnHLTaHbHvWkiRd4VHSbjAPnpUm5suycEECwe0PAPeiV+4IoVmCzQ3nb4w7MCwL0iov S6yHTn7Ljv3GJYe7aBiyPi1XceMSP1OAf8M18F3hYDgSIKUrXxEOkqUXRA0rolSGhvqA jhYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lBnKGBGK; 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 a10si11323379ejr.227.2021.03.15.11.26.02; Mon, 15 Mar 2021 11:26:33 -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=lBnKGBGK; 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 S239080AbhCOO1n (ORCPT + 99 others); Mon, 15 Mar 2021 10:27:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:36788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbhCOOAi (ORCPT ); Mon, 15 Mar 2021 10:00:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 69DD064F4F; Mon, 15 Mar 2021 14:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816825; bh=IFfqQ8qPfWnqGiSXAud+IN7dXAdtEKUe1+FwHMdPJCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBnKGBGK30qt4p8OsUDAhdJPqW4YLyczQlyjAxorpk12+m2485JQsEjNt95HegHeJ orEe6IPePAXKeqih7w5YeAffeX6Y7VGoGw3j2hSvlVXZJL0eFJj1MUd6Yyj0kVeZ28 KpAMi6ZJqGPVmeT7Yg+6pdE6pmZJwi73q2Qe1+Lk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 4.19 093/120] staging: ks7010: prevent buffer overflow in ks_wlan_set_scan() Date: Mon, 15 Mar 2021 14:57:24 +0100 Message-Id: <20210315135723.019585083@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: 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; }