Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp9297422ioo; Sun, 5 Jun 2022 10:17:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0C9E3j1sQySgU1XuFIPql41TKVm14jOgV5zFGUJvSgeRooWqII05yUWKzs9U+n1jZVRQt X-Received: by 2002:a17:907:1b28:b0:6fe:fc41:35ce with SMTP id mp40-20020a1709071b2800b006fefc4135cemr18247869ejc.153.1654449453044; Sun, 05 Jun 2022 10:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654449453; cv=none; d=google.com; s=arc-20160816; b=rFXkNZvjatjJ7VgdblW1PFYFemMEzrIdyMw0Dt8CMNTnByaM2oHdYYuiFFjl75wjW3 +OMOCrVvg4/ncSnej0i5NXt936iOPuwSZVBa8UiB/6c5P9btIFYwelqsa3jxkbsx0VSB NIYRRjTGF8dCwzYJu5xyi2IkUwIyAu7lk7kpGCSNp14nslCQX+KLSKUwkmVmvg6FXc6K GG0MFMQ132fp5KAsABLQtrQqqgaJEI8aldZwSjQGjFMm9dl7E9CbPcmi3BVWO2AB4YAm dsD3yvlBpqrJY6mkvTedKE+FOgvF1MBJmOy6X0aEp1+DvDREVx4M0xVt8w4klhYwNFyo nFZg== 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=VrmYKn6s6NFC51vuN/vk3MAdDfdUOkSk9WVxie9GxzM=; b=AgcHcveNkNGU3bJjQitv13cb4IBezs5vOg8AUzaBBC4R8TydaLQ0vD8Lc6kXN17QV8 /2ZZkjzErxGqcWqbf/N7bAV5TeM5CppD3lGhjFUHtXwRQTEW5mawpZHP/38BKag2mpY/ cbnOY2pLmeIo/wi0OaSjIcqLcNJq3HF57paRTMECyDtB3dAOKnHB/VW+oopKd3sYHBM3 muSZpMhisRqHlvzb/sizq5dRt/n+mW4qymM7h40S9mz6yjS0vcGfRUuCzxPABkp1ga1j kDpXW3MOTOj/I7PZYR7zqgFQUegJ7J+gZqrI0+egYwRTVYVJ/kPCjk3n6iC18vK+ak/y 18Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pTTLIJmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be4-20020a0564021a2400b0042d85351337si13035744edb.120.2022.06.05.10.17.07; Sun, 05 Jun 2022 10:17:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pTTLIJmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344801AbiFCRo0 (ORCPT + 99 others); Fri, 3 Jun 2022 13:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344950AbiFCRnm (ORCPT ); Fri, 3 Jun 2022 13:43:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9594B54FA7; Fri, 3 Jun 2022 10:42:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 32819B82431; Fri, 3 Jun 2022 17:42:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 891D3C385B8; Fri, 3 Jun 2022 17:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278130; bh=lXvYUp4TtvE4d7NzCJv0+s1hxA+8BpW3New4PeeJTXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTTLIJmBidaTo1xSFTmfgktIJzYg47zAz1OGGVai4POeibEQg2sb5wnI31yqPecIa mllY+4JAYlEjuRsUIM9rlwRToI91dxpXrcb7bzsWxz9+7qyk0pyvqV4fk6+laFcTMj WnXsyhq4eNRsgUpfwJcsNp0vbwHZnaDYJc5Hos5Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Denis Efremov (Oracle)" Subject: [PATCH 4.19 02/30] staging: rtl8723bs: prevent ->Ssid overflow in rtw_wx_set_scan() Date: Fri, 3 Jun 2022 19:39:30 +0200 Message-Id: <20220603173815.162277565@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.088143764@linuxfoundation.org> References: <20220603173815.088143764@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Denis Efremov (Oracle)" 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: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable Signed-off-by: Denis Efremov (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -1359,9 +1359,11 @@ static int rtw_wx_set_scan(struct net_de 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); /* DBG_871X("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ */ /* , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); */ ssid_index++;