Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528533pxf; Mon, 15 Mar 2021 11:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3MByxVKL7P1wWDEAK/furszLFwPerxL4SChrqahyocuPyEfC9b4HlS0hBrULy8kj+ROKs X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr31188221edd.134.1615833248611; Mon, 15 Mar 2021 11:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833248; cv=none; d=google.com; s=arc-20160816; b=LICIox99YGYNDeJfXSXAod8jaDbd/E59+4tAbjN5d3aJsWsmnrrixMK/0hdZB4EWlv cPJYOMC43quVqnxhTzuURDoIc5BXhpbHQ+hja1ZJd3GJalOA+ASOXqIvkeyFxNRSO8Sl Zc4IF1/A0Cn+h/cb6cpXQ/ri6qCHS+xsW4tcMLUcC3pA8HAle6XST/8/7iGF72aBkwUW wf+J4xyU7tcL117zfl4VRzOTMGb0OBGQidzBnv9v/tsIEYKHaCoRS8+WoLOUC57M2XVE GzEe+TfuPBsllceIJyyOuHcmNTcdzec9Iz8qb0vNHBq3lGTkWLCm3zFlsgvdm9YcZ7a7 KQEA== 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=roapqktlIjzIUboVMNCZEIN46D1mZjSnCqtSqlj2N/xBYn0cpJMb2pXIvQPwzvenNq 8HsYGDiwzTepya7GLXJm2g8mkzFUi0BWpJekEhxaslGnSxi7YbI2YzxY8MgKQBdMPdOO IbWIEwfG+wwKjTAJgweGuJtrugpgd98SbD77YOmPlM4l9u7sWWK6UNECrjFaMH6z0/6G ZaYlPcY4OpfURRmzHkIHH9H5AnMxRf/5Ddt4FG9MsOSC/xcUs7jd5TP8poMpmbeksoA+ REzecrLmrdOoFRR1iZp5rrYUd9/ZfV6FIGklLtpA7hHLTsdOGwiCBmcTiu2/5q6muOzO s8Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SL+LMEMa; 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 c15si2213978ejr.633.2021.03.15.11.33.46; Mon, 15 Mar 2021 11:34:08 -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=SL+LMEMa; 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 S238271AbhCOOm3 (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbhCOODF (ORCPT ); Mon, 15 Mar 2021 10:03:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7284064E89; Mon, 15 Mar 2021 14:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816985; bh=IFfqQ8qPfWnqGiSXAud+IN7dXAdtEKUe1+FwHMdPJCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SL+LMEMa7awdCXZLCNWXjqJk2dFZTZ7s/pTBa2I3kFD1FVeYXeNU1A/D/MGBciXXp K/vSG8Jtt2/4vSyDxUDp5Z3SUeTt6zKOI1KHrhhVyIVYRGLYlpCq6UlAJYEf3lEJlz KklQRavRCsMDZPFcD9otFXAz9mxhc8AtECay3qKk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.10 229/290] staging: ks7010: prevent buffer overflow in ks_wlan_set_scan() Date: Mon, 15 Mar 2021 14:55:22 +0100 Message-Id: <20210315135549.723615245@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: 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; }