Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522957pxf; Mon, 15 Mar 2021 11:26:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/J2FFKWozUCEhOMaK4PUaGvGcCDgnn4wAtYhmPzKM99WZ7BINEL0aSuPg1wW3OOhdExET X-Received: by 2002:a17:907:37a:: with SMTP id rs26mr25189906ejb.336.1615832813903; Mon, 15 Mar 2021 11:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832813; cv=none; d=google.com; s=arc-20160816; b=kbEo2SGmIobiYMJ4o1TlJ24omuW8q7thEO0HNkOez5HuZNKoY8yzbUq/yU/rOTQ6/H OnORkteFeYnP/KaKMpeDQsx9BU5Tnq4T3dfHSqd2keabyMz+25MNGFdvFuRKTEi95AGD hlBEpVVtsWgtT0IMLNRSAEztoWf39Cfa9vKQJTJvEtAQXxVwShqu5950AU5GlDBbNkh6 diMohWEB+Ted8xNs0+VmZwR5Rrn4sVxlyUT8MfBBQnROhYTpjk62ameRJd28LPILbUZQ lU4fwNSA3R+qeAfana3YAua5AuXnG+gNP9AmJbhvL1GXUidAHDTf1pY1PpllTifl2y5e XPmQ== 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=wV3XbklOgp7Z8xA/BO3T9z+VsYLid3/UsxCXrRQTQ1Q=; b=lfjmA0JdHoARXeSgKmnfv+ep2BIDkCRIqa5Cc8NSB3G2WI6veJDFo+1KpqdWRQAOIZ bhsMBdSyBDOPwcCX5k+tAGQ8Byu0r48s4cQSmnL8qPhEfZKyfpp1c0UINkG0lof1o/gr u+eGIMB4EF3Arbvf6SjRTm/bixibQBEOQra9eI4k7TR7MPMNFmrCmmO4GiAo4IZR+E2w nn8gEj7oYjxH9litBUWErz1aJOJ0/BOoelehg98TsJkeishzxa+U9gvD1t+vBg/V1Q2P 4y2kF6+oshQ28KS6xyd0flVcEsQ99e0wqrTbEY9CY0/x8/JPdQhy3/xPU1UZm4GBFafG +Thg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hNqa8KlR; 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 hd8si11218628ejc.78.2021.03.15.11.26.29; Mon, 15 Mar 2021 11:26:53 -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=hNqa8KlR; 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 S232819AbhCOO07 (ORCPT + 99 others); Mon, 15 Mar 2021 10:26:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:37836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbhCOOAh (ORCPT ); Mon, 15 Mar 2021 10:00:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ACA2664F5E; Mon, 15 Mar 2021 14:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816821; bh=Cm/Nn7sjPvLLKzeR3Jxp5wSWHSo4ZMfsZNjZY6+goL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNqa8KlR5x9m4Rn9Efrkk+8g7UkjHUveFq67Lz1xs8gBy/O1kuywdqy2LvcuV+Gl4 PtAx5P7zfAU6yw0EHgNGMNXtPtUk8L314ZscRk6fP3b/k11RrHs1+q6iYD9XJnYpE4 VP/h4csxeM49LFV1fLnl0VG/kVotoYeNAuwfuxzo= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 4.19 090/120] staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() Date: Mon, 15 Mar 2021 14:57:21 +0100 Message-Id: <20210315135722.923359350@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 @@ -1161,9 +1161,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].SsidLength = sec_len; - memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + memcpy(ssid[ssid_index].Ssid, pos, sec_len); ssid_index++; } pos += sec_len;