Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp54672iof; Sun, 5 Jun 2022 20:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw75Nbg1bZ9mlcjtdn67NhLWEXsAQfqfBUkhug7EEd7hUzs4BEGJALU4H1E/WtJMe3QE4H8 X-Received: by 2002:a05:6a00:10cc:b0:505:ada6:e03e with SMTP id d12-20020a056a0010cc00b00505ada6e03emr22401839pfu.45.1654487746585; Sun, 05 Jun 2022 20:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654487746; cv=none; d=google.com; s=arc-20160816; b=zVe7ASp2KMGTy/mRvEofDpglLjYdDKXqcYNMjC1VvQz/XHRl5MN+ef/CgZD3U/or68 y6HR1LjC0rD+Dno/FRRlbhyaIOY0oCeKxJzsZ7p4FLWiFnL/8KpCwZbUJjo6QzP4+Cmy N4m2+10sEcAYlQqFEHSi2qTthcuJCvbS9Ffz5N9coNvwoOpnP5Rgkmqd6k1HjAMC1cNg FT/3BPUn/65X4X+nKVAoxsltYj22pT4E++Vf4V335PdV5QFV/2hqPNtO+4jKIciUNpys XF3dvd/7FnGVgXvOqZi/7Ut4RPalgm1kthheyF9dtXQGbgHxPaGapM5eCF6jfMFq2OTY UxIA== 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=YdeWRxgL9eKo7zpdBuk2+Xlaje92QlMHFkI8YT7qtIo=; b=zQWuDlYM07yWqCgkXhPiuDN02DYG7pGlGRNGj9h7Ao3j/453RetbJuqG6aSwJIjGB9 UQrWlsuphjsDxeBmr2khsRs/Wyr7yJuMr2ORHZHDPnvgCAtNcbZZhftr+YHQxI8v4+Yd e7F9cPK5CNU+U1nydQmq7zm1x7uJXJ9JevzgADADK1ejokIZGN6+5M85+6oRrDd+M4Mu D2t5nWPtII6M4WoB96lqUo2fvc4f70wjOV2TAYZQmmfXg7IzNrv1KAyZtruP/zwqWTnW hDf1GeQJC2HvGGt+QzIhk0uULoGPnpQIBm8mlCgpPVlP/QrN3W18AKuqrLjdTr10L3hO WTVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1/xOkgrC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j1-20020a170902c3c100b00163bad6ec7bsi18576585plj.613.2022.06.05.20.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 20:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1/xOkgrC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27AA85715C; Sun, 5 Jun 2022 20:43:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344771AbiFCRlS (ORCPT + 99 others); Fri, 3 Jun 2022 13:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344656AbiFCRkj (ORCPT ); Fri, 3 Jun 2022 13:40:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A9B653710; Fri, 3 Jun 2022 10:40:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CC67A61AFD; Fri, 3 Jun 2022 17:40:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5912C385B8; Fri, 3 Jun 2022 17:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278037; bh=1I/4W29KUrH7k9H2Eyl8gUJVNfzH6A8M+djqcTF92tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1/xOkgrC0mgNNWsNWmgaDjr0mTyaPz/PtpEl6N0zpAEDJBo04d8V/n1/e4ewpQPNE Q/o20V7pMe63dFlcJbr1tVnXiw+pezPtJxe2AtMyJDSL9cQbNTR5jrfsNO9fdJpKPs tGxzX4BA+/EXaVRh0YecG3UrlI5ccHpL1Q4Js+bw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Denis Efremov (Oracle)" Subject: [PATCH 4.14 02/23] staging: rtl8723bs: prevent ->Ssid overflow in rtw_wx_set_scan() Date: Fri, 3 Jun 2022 19:39:29 +0200 Message-Id: <20220603173814.439377698@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173814.362515009@linuxfoundation.org> References: <20220603173814.362515009@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 @@ -1438,9 +1438,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++;