Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3523113pxf; Mon, 15 Mar 2021 11:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwQNmw1K+/3xYO2XqVhh1togw6UCMpEeg22P4SkzQaf3zyY/pNI8rKHLjfTi3oqxd2X78p X-Received: by 2002:a17:906:1155:: with SMTP id i21mr24825965eja.218.1615832825415; Mon, 15 Mar 2021 11:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832825; cv=none; d=google.com; s=arc-20160816; b=GYq9+f+IgPdXQ2EzLJAA1c76IzakPeU0darH1IRCdVH6gmTM2w2nOYAMnRebMOaT4e FUaKHn59pLo3pYCYLH/HVButaXlUe30Qj2IgDyoBD+4UCLtGhjyTJf4pmVwoTYjGq780 pyRBG0mC9PFFJlcnbYV4bghK6ZL3g1FpiWekAyvcSJEhOoBySsiinGrta60EXjChFgIH HKa01ykDOE8HJw6ChD4+h7+XK7UG2rHeTohGM9o2PLZqF3C85oX45N+z4htqNRaEqDXu FcDVeNCGyZN6wj9uavcXjGAwYCjLiuIJCvPZijhXBkRvS1MH8n9C6sgJ9L2n1S8Q8xS5 hJ0A== 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=TyKWkywa4NOLYpgjNv7VI67WKnIf0d88ROXRVtIoijs=; b=QuiIlQu5Cz/oFE8kMCAUr2D7PN12wNsjJOg4xeir1OeLUCQblT/JOvqeo++XvWNgiv UHI7LeUYevMygiJ6H1gus8MiCksrh7eyvk5mXIIllzbJmd8S5miiP2R3FD44C6nfogPL tatVgofle3OWcZMspOT6GER1IX3fiMUZdDvLBbQEDcD9C9reJGYymj2Bx90EM1veUJpN 3NUtPoC0Pqxe/PisgTa3pTUV2htySvHeccHGTXNdceIwstolinv+QHjbaMLAUm8/yafZ AZjSUpnkVxMCAR7yokzZS8O+0uKTtLNRlpish57BeNU1UDnp68HoVwsfosVJEtF+NRDx aySA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PIJj602A; 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 hp15si11608616ejc.548.2021.03.15.11.26.39; Mon, 15 Mar 2021 11:27:05 -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=PIJj602A; 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 S234507AbhCOO3E (ORCPT + 99 others); Mon, 15 Mar 2021 10:29:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbhCOOAe (ORCPT ); Mon, 15 Mar 2021 10:00:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5AE464F4C; Mon, 15 Mar 2021 14:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816815; bh=SXADVo8Yb/2mRNIQO0kqwvON3iLkHdNom3HkGt9LJwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PIJj602A9Tq+Vi7qlKvybJkZJH6ACtBYKR07K1EItnIBR+dQL4F4as4rg5SZaqOvL XNMJ8vYdvP1g4Kx66/Fu68R+9ctdxfT+EOilMkN8XC/SgxMZMY07vhrLHJHr4ypUAa 9rP/l83Vie0wXNN7l/8cU0goR5w9MBt2Eu1GwVWk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.4 128/168] staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() Date: Mon, 15 Mar 2021 14:56:00 +0100 Message-Id: <20210315135554.553968261@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 74b6b20df8cfe90ada777d621b54c32e69e27cd7 upstream. This code has a check to prevent read overflow but it needs another check to prevent writing beyond the end of the ->ssid[] array. Fixes: a2c60d42d97c ("staging: r8188eu: Add files for new driver - part 16") Signed-off-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/YEHymwsnHewzoam7@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1160,9 +1160,11 @@ static int rtw_wx_set_scan(struct net_de break; } sec_len = *(pos++); len -= 1; - if (sec_len > 0 && sec_len <= len) { + if (sec_len > 0 && + sec_len <= len && + sec_len <= 32) { ssid[ssid_index].ssid_length = sec_len; - memcpy(ssid[ssid_index].ssid, pos, ssid[ssid_index].ssid_length); + memcpy(ssid[ssid_index].ssid, pos, sec_len); ssid_index++; } pos += sec_len;