Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2221544iof; Tue, 7 Jun 2022 23:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUk3IqeoKhh0vAZbws+nvnmeqiebxPlIg7ZfCWjfKQUf50zhHLIPGzEdksJHsXUkXgMLZ4 X-Received: by 2002:a17:903:244a:b0:167:74f3:7463 with SMTP id l10-20020a170903244a00b0016774f37463mr15894198pls.44.1654670335999; Tue, 07 Jun 2022 23:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654670335; cv=none; d=google.com; s=arc-20160816; b=NMvJA61MMRbSNHDreGLgbMhbN84V4qtXPYHuVD7rHaM62fIVktW8Y85qw1bfpcmLOV 8SuhspSvT6SFGGz+ATXq8+uBhdwQiOq/HmKQNcDOKMpE7SUf1iBOJUtb6RN6VGLoY1fa qjyqFUSuXUkgLlBvu2YOsMCOEj7Lk46YOJHZ54lUDNaAgDPpW2YWUu95V2Yic7G2rALk KCtGBnKZgU+xl3i267ZetNpxwEWdo26ngrKzt5jy62oVr+ObhbqCgLetaFkNkoUNVomZ E2hkWx6B4PFHIJqrRuMDq74uMw60DRh30XowW1vXyWihgrTgcHcWQQWnGHY1EeUEs9Gi +YOA== 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=Yubd4hvE5q0GPGK3DPpVAzSlPiQVrKQ6dFbEtOKfvCQ=; b=LX1L01M1mZtl+kIUmtFz/JbwsHXn4hetnRieb9ciPuDz8n0EPXXqeuyS1KZ/NlIhuj MxH+gLUP1LeRpBEVfu8AU+fpT9aSTC4kEAznhx9uoRDTUX2K+sS0x5vpQp8orTIMVG92 bbHGYB03DZYyoYOWatF9KOkXcOROZ1VJ3AQbDCGx6MUx1GZqmJhd9rnIhw7F15FOUfP+ 05Smo/YJ0DQ+KQKroVH3rzoO7noZZWZeJ8jeJDGKp+1pYbSpjN3Gcwf5g4K7FL9goMK+ y5Q4EFP5axuAPzRPcb3nofO4Zy+/2F3c/O+rWx71rPSlz/2OK+yXymoV+4cwWpYbGOpE YaMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=znMTv+aE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id c3-20020aa79523000000b004fe3a6ea856si25678719pfp.176.2022.06.07.23.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:38:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=znMTv+aE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 BABB115A740; Tue, 7 Jun 2022 23:01:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240677AbiFHC14 (ORCPT + 99 others); Tue, 7 Jun 2022 22:27:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446938AbiFHC1A (ORCPT ); Tue, 7 Jun 2022 22:27:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D72DB262ADB; Tue, 7 Jun 2022 12:20:33 -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 24221B823CA; Tue, 7 Jun 2022 19:20:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B394C385A2; Tue, 7 Jun 2022 19:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629629; bh=ZDnKYPmPQjxcm4FY6FcGynN3YmPDyHlU/dvI+MVgxa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znMTv+aEldDwRuBF8lEna0JBeuWnt0vJ5MSKDD60ZEUtPspqnv26ub13jooCCSd/g wfgQmYbFt+Mof7Q3tLUMDVrcgI7ZY2UZfmQI6RSlNQP+5MIG8EpnMjvKSl3FD4YbDq v7G/DNjz1z7EBM5iLocs4XUKFHOpuO4n5E6hUi1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Denis Efremov Subject: [PATCH 5.18 758/879] staging: r8188eu: prevent ->Ssid overflow in rtw_wx_set_scan() Date: Tue, 7 Jun 2022 19:04:36 +0200 Message-Id: <20220607165024.865883010@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 commit bc10916e890948d8927a5c8c40fb5dc44be5e1b8 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: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver") Cc: stable Signed-off-by: Denis Efremov Link: https://lore.kernel.org/r/20220518070052.108287-1-denis.e.efremov@oracle.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1131,9 +1131,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;