Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4607486pxj; Wed, 12 May 2021 09:08:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw20q2qescxo7iNQGAwnNz4eAie8nBRFNE8WIJ8+ye1MdAzqVu7iPqJ+hrUZ05X4gAitaC1 X-Received: by 2002:aa7:c98b:: with SMTP id c11mr44480254edt.50.1620835719599; Wed, 12 May 2021 09:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835719; cv=none; d=google.com; s=arc-20160816; b=gk22bGAm5MREWp72cNNkdoJuxryTNxmMJ9IWQ02mL/eEPEHqE5UOvz1LmmO0WufPhF Hm6yw6l7H2LJnn/EMr8MTKer2lf7J7Qb81MZQcYH7aI0BClY+0eLsLZwznCrJGjlU6rp d56mF8P8BcFDMLz3ebBwxuslk30zQe8PkIzo9NQrL2LD2+GPCgJP4cHx029L6SPiPAEr tn8GjXWaaORHAI1+4yNjSzVpElozHfx8nrWcTR1IRy/6Vdji35KyltjQnLHEnRzHZXKB AsjXYN4IA62Rwq8u7ZAme67ivHFQ3Pc72PuKPtBLkLCjl5QQXCpZUqaTq+U1aVM28g0H tj5g== 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=OGVhvPwfqSIsgIBY2OystGILMM+4HqtbbO7EQO1jBlA=; b=FeHE1QF8VQ3v/mJSegr37epbSltY1qVCe1HOC0gTy3PYk80/QfbEySf3mu2Y31UZb6 ZUFcOI9mPTXKTZV5+ECgx9bJTJRJLsWMK3lZqYq3O06NJNfrH+bCJWaCjYx+phKk9K3g gIGulY3f10M4EgkfUmO2Wq47guibZDa82l4RKPj3jGeOj6h0ofeAfSs+MbwDVDahSErK /fHZBkBAF1VUazzUwZMBR50qG9m1lVX2qWo13bALChVc7O/7ZcMSqXe3AZ9lJgM9nOK5 q/Tw8XDCOpHKntHSC0fR/Kr50Owsx5wuI/i7avQB6ULXshwpftPnOtOfaxst+F02xV3T Z8rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XqJhI/El"; 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 b6si451911ejb.398.2021.05.12.09.08.15; Wed, 12 May 2021 09:08:39 -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="XqJhI/El"; 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 S238987AbhELQG6 (ORCPT + 99 others); Wed, 12 May 2021 12:06:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:38508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235581AbhELP2e (ORCPT ); Wed, 12 May 2021 11:28:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF84C6162B; Wed, 12 May 2021 15:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832437; bh=BVMU3AVTnR7eWjaKGZrx4Nx13u8lYUd4M6mEbXxRxTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XqJhI/ElAzCHZCNPngRySoYkaaE7/wGhQxuiQ6E/5xb5In5YZ1Msn1mNIRYGVdnMC MUg+fzGyvNCDnRQ5NWuduidurTbgj/QUxVav+8BsDtcx5bUytx0gMYB554BuOMkf45 ahKM3yVULi5dNBbIGQELKOhDoecavFWmfgz7icnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bhawanpreet Lakha , Dan Carpenter , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 279/530] drm/amd/display: Fix off by one in hdmi_14_process_transaction() Date: Wed, 12 May 2021 16:46:29 +0200 Message-Id: <20210512144828.980409194@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Dan Carpenter [ Upstream commit 8e6fafd5a22e7a2eb216f5510db7aab54cc545c1 ] The hdcp_i2c_offsets[] array did not have an entry for HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE so it led to an off by one read overflow. I added an entry and copied the 0x0 value for the offset from similar code in drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c. I also declared several of these arrays as having HDCP_MESSAGE_ID_MAX entries. This doesn't change the code, but it's just a belt and suspenders approach to try future proof the code. Fixes: 4c283fdac08a ("drm/amd/display: Add HDCP module") Reviewed-by: Bhawanpreet Lakha Signed-off-by: Dan Carpenter Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c b/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c index 5e384a8a83dc..51855a2624cf 100644 --- a/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c +++ b/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c @@ -39,7 +39,7 @@ #define HDCP14_KSV_SIZE 5 #define HDCP14_MAX_KSV_FIFO_SIZE 127*HDCP14_KSV_SIZE -static const bool hdcp_cmd_is_read[] = { +static const bool hdcp_cmd_is_read[HDCP_MESSAGE_ID_MAX] = { [HDCP_MESSAGE_ID_READ_BKSV] = true, [HDCP_MESSAGE_ID_READ_RI_R0] = true, [HDCP_MESSAGE_ID_READ_PJ] = true, @@ -75,7 +75,7 @@ static const bool hdcp_cmd_is_read[] = { [HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE] = false }; -static const uint8_t hdcp_i2c_offsets[] = { +static const uint8_t hdcp_i2c_offsets[HDCP_MESSAGE_ID_MAX] = { [HDCP_MESSAGE_ID_READ_BKSV] = 0x0, [HDCP_MESSAGE_ID_READ_RI_R0] = 0x8, [HDCP_MESSAGE_ID_READ_PJ] = 0xA, @@ -106,7 +106,8 @@ static const uint8_t hdcp_i2c_offsets[] = { [HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK] = 0x60, [HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE] = 0x60, [HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY] = 0x80, - [HDCP_MESSAGE_ID_READ_RXSTATUS] = 0x70 + [HDCP_MESSAGE_ID_READ_RXSTATUS] = 0x70, + [HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE] = 0x0, }; struct protection_properties { @@ -184,7 +185,7 @@ static const struct protection_properties hdmi_14_protection = { .process_transaction = hdmi_14_process_transaction }; -static const uint32_t hdcp_dpcd_addrs[] = { +static const uint32_t hdcp_dpcd_addrs[HDCP_MESSAGE_ID_MAX] = { [HDCP_MESSAGE_ID_READ_BKSV] = 0x68000, [HDCP_MESSAGE_ID_READ_RI_R0] = 0x68005, [HDCP_MESSAGE_ID_READ_PJ] = 0xFFFFFFFF, -- 2.30.2