Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4671400pxj; Wed, 12 May 2021 10:31:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq18zkKVKYb2tBMC22EeAscwTFQBaEXrfpJAmhGW00tDGDErfyqEcSAzXP6MGpnuM6x+ei X-Received: by 2002:a9d:728b:: with SMTP id t11mr26207776otj.230.1620840713203; Wed, 12 May 2021 10:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620840713; cv=none; d=google.com; s=arc-20160816; b=jHh5skErV7yQwK2mPw7ojzerFHBnvggt4jbon0X0z1wiH76BdRubq4SICi8r+cOYGI LYl4uSiiOwOgYkqZNqK6eebtrVYg1HKOeYD1OuKHNzahGnAdnjIeHRvQpmcxH095+XLS UNT7nVFm9YRXr/slTyzs/D0gV2s8x2O2d4TFVC1q+MXSeNyjHuaVY1qtNHTYvCGRO0+b jy7royADVRkqdq1RRe0lgNkvDh1ABXzjw8cCbMG7LwIGVNXIVQLw9pCPj1t7rF6Tfgow T7unmQf0pOGq/8Fooqt02tw24F372Ue+9Kln7B6Urqzxd/L5D2IdTmvx0uUdYKd+59Bz faRw== 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=H7qMiJylmvpyIVVlWWffdVBmbJ7ZK6PdnmnOeMXKGfKiu94B57avBdqH7hAhQc34iJ uBQ1QqVeYAL+W6O5c/i0ub/VjkUrwirfS9eNNgbvq5uiJql5awGaEr2X1LCMmcVQ5Djx 7szPg00h5bhvjWndccr8rTu+hKXZpkf4YwzN45glvxhpR5PztbJtWlD2vK0fmKCCy/Mc Bl6fCp3YNTBjjW9TLKb/veDDZBBHHxoRqZV4vtTGdeQCxrQJSLuX0NMp5oH+6e9/kwu7 AMgnY8r5XFvuJ6X4o1nXOu+BUuc9Cw2FYvB6D1v4OtMKFGuGGYYlq0blnTW9n7XFzzhd 0HWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yceErwNI; 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 m7si466602oom.18.2021.05.12.10.31.39; Wed, 12 May 2021 10:31:53 -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=yceErwNI; 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 S1347370AbhELR2R (ORCPT + 99 others); Wed, 12 May 2021 13:28:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239301AbhELQHu (ORCPT ); Wed, 12 May 2021 12:07:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56F4A61492; Wed, 12 May 2021 15:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833837; bh=BVMU3AVTnR7eWjaKGZrx4Nx13u8lYUd4M6mEbXxRxTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yceErwNInJ8j5lz28oxuZJAZurSKKhKIVBGNfrvts/VzS5RDjFSZvPoMpMmK0wCdg 0qQwizGdmG4f4zi2ABSW22vG7RwY04FH872KSQcnBzcpkT2vpYDEDm1Gbjn4ViTOAo OxbMrQfCRV3/79rRf6omuABOLYq13ABGWe4puc1M= 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.11 309/601] drm/amd/display: Fix off by one in hdmi_14_process_transaction() Date: Wed, 12 May 2021 16:46:26 +0200 Message-Id: <20210512144838.001168962@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@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