Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528534pxf; Mon, 15 Mar 2021 11:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZtNEI07rC5NuoMMSHcHjLCKPSTHijlDs7jofistH/QWOJWNhV0Po3qvCDZ6bVCzpkBN/q X-Received: by 2002:a17:906:1155:: with SMTP id i21mr24857213eja.218.1615833248576; Mon, 15 Mar 2021 11:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833248; cv=none; d=google.com; s=arc-20160816; b=YFeDt3VON8OHHGXa7UJ0AuLXFRY3TdTYxOD5FTJhXB8hGDRWTIVoYhDuuzIIwASpmv /OMdB5eC8TQPjNTf8Z7SiFQrClNb1LWexs+6gTxG8aqXwD6Dbq329Fvaosx1RYdBAMBX 2np60w8WvhyVI3HVbBvwzmSv1wCfXXc3F1nt0ie27R0ME1RgmNxFHKHzaJ8KhEMyFcxD xlQd19i9gtDpW2cDjW3R6uUkxOiGPR4ZmIsYCxDUK2+A4o4OWEebN/A2/UggF0wfnTvV IEYbXlhxxNDIe0JOtHhH+gHA+DR1RLKY0xBSt4U2ANOchGlC6W1q1wgE7/a/lTHiDafe Qc3A== 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=z1tbpbziH+FQW2wHWVpbJLG3+h/2/vDX/VUMKE7Mh+o=; b=ns///0vbnzlhqV9R2+CGGt+CIC6ymu478zRyrbIFzn2jCorrmQUg/pHvURpK0lt3gS KDL/XWaRDQxm3QDE5Ik2NyG74uhdm9PrPPWYfLT6KbgmRYAappekzqM2g0frbh4dVLem EY4sjV987ovhow05en/VVPRgF34ThyJJV8raGaqPpYeqkztjz6hxahPvDIzzBtdeRHCg xu5sQEbbttMTF+ZuBgw7vD7ASPcIgU4m/KKObLFLR+C5ZpXiq9qbQ6hFJi367tE4RwIY I14XshWLs/R/spWTRFnpFCYwD/wjwsHuzmLcCqaCO2qazYV9p9znjVMtuxEOQR6MmpzU 3GZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RAANTUtH; 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 x20si11158652edq.132.2021.03.15.11.33.46; Mon, 15 Mar 2021 11:34:08 -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=RAANTUtH; 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 S238301AbhCOOma (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:49528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234244AbhCOODG (ORCPT ); Mon, 15 Mar 2021 10:03:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C76AE64EED; Mon, 15 Mar 2021 14:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816986; bh=9XsMaaOiAspY5eNbUTF64jnvZ7fk4hGIKdA/MsveCG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RAANTUtH6BBjpVeX+Zp6/R/tATw7apkwBciZtE/IxFK1uWRrggs+1zC3XwnSVwBM8 bdzN+JnPMZs56+GkAzcYhJtSWs0dT9aLpy4lHVojJfQQI5c25PAJuW24qh6N3LC2gt l2ZgcuGPTO6gKdOTf0ar33mYL3MeEtywNBK2cs94= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Gibson Subject: [PATCH 5.10 230/290] staging: rtl8712: Fix possible buffer overflow in r8712_sitesurvey_cmd Date: Mon, 15 Mar 2021 14:55:23 +0100 Message-Id: <20210315135549.754227637@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 @@ -192,8 +192,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter psurveyPara->ss_ssidlen = 0; memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1); if (pssid && 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);