Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522817pxf; Mon, 15 Mar 2021 11:26:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH37CzCqhRE4IlAZ8V+2+kHgv26P6rdLe6rgL4ChCedMf9XUU41p3ulyteXmdb07YDxMs0 X-Received: by 2002:a17:906:c051:: with SMTP id bm17mr24657744ejb.21.1615832800541; Mon, 15 Mar 2021 11:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832800; cv=none; d=google.com; s=arc-20160816; b=Zf+JXsbHWiqzreiD0+/+SPnphH0yrOMVm8bY1QnbivJeZLCxIguCbwtrK+CH0ybC3x QKPH1nXCHxEy6CD8Yiek/QmWJ7e1HuzQ68N7ZIKLeil4YK55DBCu3EgT0i96B1i9nfba 6VX6gMHmV1nkwSWIasB0yg8Rozh7W1yXUCisi/82ZwAW18siU+t+MfF19VfIXUEzg94U gYoXZQi34u7mVLrD3/dCZ4nmKQqaxJ+ZuJ/tZ9PpwyheluONuswzmBF/8BjYsp/Q2PoT oDVjuiKfGdMyT1hv7jI37ZsTWKwycm7OfJ2oX8NlfBHiNEKMbQOSB5TipARdGLpt6a5Y BV/w== 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=g43uxFlHTXGBEVeHzMKXjzm1V5a2V3ggXTNv0wn0hpM8JymxwetbnXJ0pTon4Ymgx5 gA26vBN6ABo5ja+cmx4vkLt8yDk5EsYGzysTFONk0ABVfdQFoqu9dSkMoSTI0Y+BUSmy EDNWyd4FIJ01eeXYdeTBTmiU7bKahbD5JAvctzwRoi4iHj+8ushQuLEn/3OalgW09HKV PYkrgdBP3leyfYRmVxksE9Fi02kiEFQ9pMCV03EHwNutw0SfIfbEiP7sWwicZm8woWvL HsKIAKlrts9XIbe8qufhnw0PP1pvPqaAcWoEDivNBNELe0yB8eWER2TF+0GTkBJInfF4 +S7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HbVX3OnX; 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 ga24si11229063ejc.422.2021.03.15.11.26.18; Mon, 15 Mar 2021 11:26:40 -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=HbVX3OnX; 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 S234464AbhCOO0w (ORCPT + 99 others); Mon, 15 Mar 2021 10:26:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:37500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233055AbhCOOAf (ORCPT ); Mon, 15 Mar 2021 10:00:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87E4F64F37; Mon, 15 Mar 2021 14:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816819; bh=IFfqQ8qPfWnqGiSXAud+IN7dXAdtEKUe1+FwHMdPJCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HbVX3OnX3sqAyqlXpsHAX1sIE4s7XdH1jlbY2zVAMoBLXf994y4M/AYTW/dBSvumS Mf8pwgFs6beUTwgcHleDspzwAefjK5jJ6OkxEcgnmWiyiwwqD+tdQoCJRv367ldHC4 rgRQ6j3pzN8al8Vku3tpSHk8/HD47G6S1tkEM3IU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.4 131/168] staging: ks7010: prevent buffer overflow in ks_wlan_set_scan() Date: Mon, 15 Mar 2021 14:56:03 +0100 Message-Id: <20210315135554.647688271@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 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; }