Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3524346pxf; Mon, 15 Mar 2021 11:28:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVBWJ5TikQWPqbHxi0W5C3tu1HeFzt9mmBBMaiEPYjiOO0Gl2LYJzqy8kx2nEeNO6btnuQ X-Received: by 2002:a05:6402:1517:: with SMTP id f23mr32248502edw.272.1615832915208; Mon, 15 Mar 2021 11:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832915; cv=none; d=google.com; s=arc-20160816; b=vbFeEOMTF/6svwB3DgN2ujIbaH+D2Y3MrtIGr5HYDqj0GhVZx3Q2BXkVqG5pg4vfWI HWdJwYrYenKizW4UE1Au/E7cfV+S1Ros8eDb6PN+aDsydD1OwNxBkRVWc3dv9ycYoIFy bLwgRnOT/nyuoQTQBuG0wZfMN4i5Q9+MA4ZFY1NFfBdowCCeUNXkFc110gqZY4N6yMpS 8C35sau3OrrFlN3c/e6yyBtaSABCclrW5AJmU99wotalAMZ1H/3FfdW+nBGZ+OIYsGg4 1x0G2qQavsGgpLnew9Io6WFMRX5zcaVWf6DJMmSBUJeg+Rz5L/vz39C+uq4uiae8caSO XyLQ== 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=ipInAxjcuTW381v8jn+5UIsKAGIGms8TbsbSSXyRhmE=; b=NzQk3knduZVq193fpetlpQkmdCkWYCKMBGpaLOPcOp/9MQpul4Ho80aDsIaNeX4WoK eTvWkQtlQVL+aIU+jV9kA3qh8Z/HLc+blBNOF1joKIaxTVARCslE0+jFcqY/vCAeyDF0 SMv+X/NrHQyCGnRTn+HU8ENZTN13iJYyp5AvFgZYV58J/+ZnX8ivfB5Sh4CZKN+IgcXY Q7zxJX3K9GL6uL+MhMi0Hnyba4Q2WhpHo6WkQan+mCN9wbTAExlnSy2ssN/U10sJePuz SqG6MZftlg7XznDli6mKZiPihhzwlUSce2ULJ2N345KWW0MhA7rlItN6XUf/BfjHq7l1 7zsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JjQzn50t; 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 4si12699616edc.257.2021.03.15.11.28.05; Mon, 15 Mar 2021 11:28:35 -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=JjQzn50t; 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 S233115AbhCOO2X (ORCPT + 99 others); Mon, 15 Mar 2021 10:28:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233073AbhCOOAg (ORCPT ); Mon, 15 Mar 2021 10:00:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BADB164F0C; Mon, 15 Mar 2021 14:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816820; bh=vl73W6qv2GnwmmNAiIt3sPxQ4yI16j8TmO6sb1RErJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JjQzn50t6TJyWoYn0V6FoDayQbyGCP+sFAsbhWjbhETPO43SEzYVpoaKZ5yze5Dl5 JxFjwxkMODgCiLTXs1ySCyX2hsGR0AeRB+IF66C1tYe7sLfmyFJa8lWz8DqrutWfVi 2YX+EvQqjX/OcLFD9PYH6GyB8cvFj9EaUof+WR4s= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Gibson Subject: [PATCH 5.4 132/168] staging: rtl8712: Fix possible buffer overflow in r8712_sitesurvey_cmd Date: Mon, 15 Mar 2021 14:56:04 +0100 Message-Id: <20210315135554.679707650@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 @@ -197,8 +197,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);