Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3524079pxf; Mon, 15 Mar 2021 11:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2xIti2xeIAbzK018LRfKxAxL6c0TrwpLROWjwdyRfwWpm0wCuHpNSxFuJEeDfCXN9GAtC X-Received: by 2002:a17:906:ecfb:: with SMTP id qt27mr24809309ejb.245.1615832891352; Mon, 15 Mar 2021 11:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832891; cv=none; d=google.com; s=arc-20160816; b=uEgGsIag2uhvPVtaXp71/GgZjY3SVAlhWYQQdWCXbXfrQq7CtMFs1pIsoLDma2IAcW brKYaaVgbxvpVM3A1GODCnySAUcyAKWo8T9Z34CxK18UL/YwMLQ781ytl8jotNnuXmDt v1A1K/qEdOAXz/g1X7UdtYBo+YPU2P2QWfcvShhCNkFRZsJGMPT067dMcbIZTMqrnXyd 2ulsd4/DYG18NSilYU8L9utHOh4mchseXQZDYjevfldFjQdaJakkAuhx0bSLT5uZeIIN OOe6eB+wGaGk3BYSAZKIAj55W47EHrWfLActuFB69jmiS0zoUGLdVE/DniDccbzA/cna yLgA== 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=yphqEfQEqLBn6K6a3qAyH5xi/+mQAjTMdilBey3+Gpo=; b=rBFBnB+eOQXw481mlRODcQG9Gk5rS3QzBkNV6SJ1Vq2GccOoduu1lS48h7s11OLR2I PLmCFZFG0rnUJWw01LKpE4jFk2yVqMkBG1HevVP77Y72oKuioGCmNcnrOeMkJrOkeicL T9aH15hIGdyxm00y6eYOjCdDSA/Sy3jzjB5gsPIl2lOdpoJdFgknYD7IvnPU5WbdFQJo sSzM8PlGOHmzFUlD+LRfCCfCC/bloHPmhRh/9IBlVae7Xg+zsbSJLvllAiyUMyJ47pfi swziWWBU9D34lp0PARyXUS6+AkCnBOVSZ9Tkjbxk31sx4ZmFe1InkXTdtCSl2rVE5Us6 09Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JyR2XtoH; 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 z7si10895962edc.356.2021.03.15.11.27.42; Mon, 15 Mar 2021 11:28:11 -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=JyR2XtoH; 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 S235517AbhCOObC (ORCPT + 99 others); Mon, 15 Mar 2021 10:31:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233038AbhCOOAt (ORCPT ); Mon, 15 Mar 2021 10:00:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A39B164F8E; Mon, 15 Mar 2021 14:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816826; bh=UX9f+NV9wDx9Q7CmnQqT1xrjNeuvz9LnWyiBmFrWdwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyR2XtoH/cqJBVTXWYFxe+MngcdIT+M4To3jAQaj48b0120CM4FlbKyG7CJM9l0c+ pgvEhpv3XBQAsntTp9PPX6kg6i4w953SR220SYMmLk6KY+XMd4KuQatdJdv3pXnm2D cyEoIeQt+Jo9RSs2Iea5FL071st/vPCxbbSW5wUM= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Gibson Subject: [PATCH 4.19 094/120] staging: rtl8712: Fix possible buffer overflow in r8712_sitesurvey_cmd Date: Mon, 15 Mar 2021 14:57:25 +0100 Message-Id: <20210315135723.056930586@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: Lee Gibson commit b93c1e3981af19527beee1c10a2bef67a228c48c upstream. Function r8712_sitesurvey_cmd calls memcpy without checking the length. A user could control that length and trigger a buffer overflow. Fix by checking the length is within the maximum allowed size. Signed-off-by: Lee Gibson Link: https://lore.kernel.org/r/20210301132648.420296-1-leegib@gmail.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -242,8 +242,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter psurveyPara->ss_ssidlen = 0; memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1); if ((pssid != NULL) && (pssid->SsidLength)) { - memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength); - psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength); + int len = min_t(int, pssid->SsidLength, IW_ESSID_MAX_SIZE); + + memcpy(psurveyPara->ss_ssid, pssid->Ssid, len); + psurveyPara->ss_ssidlen = cpu_to_le32(len); } set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); r8712_enqueue_cmd(pcmdpriv, ph2c);