Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528101pxf; Mon, 15 Mar 2021 11:33:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVU6jIf5dJo/M+RHUcJ+MLpHcjtvFVlZ4zxGatLulS+rC4RXzm1UrScMY79R4jqPFrKDpr X-Received: by 2002:a17:906:f891:: with SMTP id lg17mr25452229ejb.69.1615833212962; Mon, 15 Mar 2021 11:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833212; cv=none; d=google.com; s=arc-20160816; b=PEk6d60TGZBKxdrktVvFp8u/9QBEIyc0PyuRqljROsUz+Ad4/SnkVOoUy0kBSljOiP VpahIeOhMq4HlqeQQi8DyVRJE7Slp/Njwp9C3ic6/wezTFw1LS9nXeihyr+JDQG+ENkU q2U460FcFfrF+pjx2wUAVNPIDZTT+yqWan75fCfeaGdXgKnnypAS7CRyFqeH86QXxjN0 vmlr0XEWSxUjGUtZQt/uNF0keurmNK6xXfZ1JEzcGq3Z6vuWnb4gfGoYVe1D7TgliHio qixfq/ayIK6bPFQMq0VQoMxIJ5+59l9R0dnBFNBDOjldhG1Q/8mcTRouQo4S79wmcquu 2v1A== 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=Xigt3RkDiqCRisSQeHMFM1uGd9/TphDCrzoOdDmHg5w=; b=RK99HiEazWnJnZZF+X2oLwvI/4+w3EojRmudCzc3Yow3nhmp33BUi59DIz0CHtcv3b h5as6tn5HWidN/xd/T4ybQLK3BO7eFYs6Sppg8n7AIe4BBNUd18Y9c1zZ70GwjHbXTPl AEu7JSgJEbs8e6Ta+hzT8MgEF0KH7ZP1ytm6bz0yAfFNaZKDYcvLsl7seAIQvECavXeP 1hX3hoYYf0LJ3zZaD6AjsVFxvuaChpo+kCgVKAMyZgu/P9TqmbENKRgiHrZR8vZGU/kq aHfGvoQq0kXNtU8TfZEpBfUr6gLBTDNPGeZu9zo0REeTzJrwuAJ+km0VKSK2qLcGLRqS KGQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CRDycruZ; 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 g3si11521561edp.527.2021.03.15.11.33.10; Mon, 15 Mar 2021 11:33:32 -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=CRDycruZ; 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 S237028AbhCOOkX (ORCPT + 99 others); Mon, 15 Mar 2021 10:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233822AbhCOOCa (ORCPT ); Mon, 15 Mar 2021 10:02:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8F1864EEE; Mon, 15 Mar 2021 14:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816949; bh=34MAatETw390iFaJMxlIqZinjhP5s/FrkGn9Owbwa+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CRDycruZ9xJf1hQk6pVX6ByYwC/tbefwbMzNpCiDYWYTTLsQYYKH904pbE1Zr4+bt W34Z4xOHekgIzQ9ymO1tInltIY75GAEduwzVjTT5u/HZED6i1lGCKYmFfljGvoU1UX ns80wdhuOOC26Z1RsTQooFdwIkeBNqyVX3N7M5zI= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.11 222/306] staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() Date: Mon, 15 Mar 2021 14:54:45 +0100 Message-Id: <20210315135515.129071157@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 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 @@ -1133,9 +1133,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;