Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527358pxf; Mon, 15 Mar 2021 11:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn6rjAGsn2jVGwytcd6kJYK/6GXSOxYQ+vEAx13vFLfvkDTLoV1PamuTJbzUB7hmrYQKD5 X-Received: by 2002:a05:6402:8d7:: with SMTP id d23mr32231415edz.256.1615833154715; Mon, 15 Mar 2021 11:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833154; cv=none; d=google.com; s=arc-20160816; b=0i9/b2nwWCR9nXvj0xFRmZ0TzieTSiVgJvPZNnaXsraz/ZVj+9QY1podJt8JMesHYZ 8sTWadUHJXBOoAiMBNnRapc7SwAYIIg8SKB5IFHwd2nm1njaYHRksmuwd2p2PoO4+825 IkTqHJdIC26QPY6u1amO01aiR4pbBEg651rMO3zG7bkgd6i0FH73v5khAK6U16lLvWGa OoefhOoNoym7YJD3PIr9c0I1/YzwdXBwaNEgyRRpdAJ4htyi4ZYKIJZNMjMNTuULaqwC FWu2JssJomtRQau9mof+2FLkTyYV4Ed043zRSgG3LteT0rxm0A7Nl4iP/pJpHmVhhdmt muGw== 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=nAIxVvNfRnBWKvfeM8zBfArfGPjxS1Q8VHa/HEZDDZc=; b=anfJWEWeq4Yp2LcZKwmyBZfU6SBNG+duJ3hTzeX04MGlSQynLQDVr/UZWR3i0vPCCd /M+i7sdbLZkoXozRpHLGNXbgLtUwCC5FWIwTS/KOC5GCNivg59xQ8ltXQoQCULUV6+kJ nlFavmOOskpK7qUMxwhA589rbiLuekyQ90prcURYJArTmCmY1a346iyozUS84hXJVCaw wFjh3C2rwfy89XnRYnEFsIUi8J+nIsllHFA5KCA1wumuYoKMfyw64BioL69VDdO4qnQL Kz+JalFxBnHQv5Ww3Q3DAIyD/RGU/O3BZuex9YeZRwBXWFRuKt8pRnDje22GuZmwF3iO NwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AApodd06; 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 la25si11624132ejb.703.2021.03.15.11.32.12; Mon, 15 Mar 2021 11:32:34 -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=AApodd06; 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 S238107AbhCOOmT (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:49458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234173AbhCOODB (ORCPT ); Mon, 15 Mar 2021 10:03:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4978D64E83; Mon, 15 Mar 2021 14:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816981; bh=t5BnTS850+jKKLw5mVittI7sbVkHlpa1WiKqMPxCEdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AApodd06/DHAKcKfnYH/mll32/s4Aj+63p86b4OC+1iF5UGKHParXh4jAW67ljPYB HQqAZeb2XS91f7HMdKLMc2ObpyxM4A7UKgSfC6e8utkrgT30ZRM/YhfK5Y1e8jIO4l 4MS2PINLhK/oHbZ55HuN+9HmEARS7dmEt/wszAlc= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 5.10 226/290] staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() Date: Mon, 15 Mar 2021 14:55:19 +0100 Message-Id: <20210315135549.618983186@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 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 @@ -1144,9 +1144,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;