Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp626519pxv; Thu, 15 Jul 2021 11:53:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcsxY8JfHhHc8mN4kHejbtOkgwjBAtLIjexxSNxM590nVlK/45Irq1+1Jb08HxZcKRhV+6 X-Received: by 2002:a05:6602:1544:: with SMTP id h4mr4255431iow.76.1626375217288; Thu, 15 Jul 2021 11:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375217; cv=none; d=google.com; s=arc-20160816; b=iRgVAlFSY3R9IqZ/diO/paXz1QuRdlm4f0CAxj+asA5Ra4+nEiw4USTNOa/u0kttAV QyNBQzZau0/vZ83b1vQUzjeIuS3KCne10V9PVDdnOP914AnEQIkxtQRNsSkvPB25SLBK qoXUp52vM/NsxttAeCB90WqaIfZFDSHiGaIHUziDJJ7XQiP0/7Eb1D52fw/+0Km4jVOG 6FahPFQOHe5doGMRnBTpGIEQcP3gLd2HDRrzzihxbNh+j0jiH/kPHe6imdJ233Zr6CfY yiNC0+hazTpwuJ0/Q9sMNYU16eWo4M9CeTlyPuoVtC8AvDpvTDKwRzoW/TVV8fQ/me1v F4xQ== 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=C8Ktz7giV4VKRJM+hqaSOtGRPV4kS1G5loVLXH9D+7k=; b=IydM68IMd6515p/DL2Is8V4Z+CYBO/7zE7jeXaGnToXZ7ThbKUjUZCgIZUWkRGaMO1 IFYj9oEpDzmeZ1HC9GJLdy4zpm2Y+rxOckTnjkW9oad073XPH6cbm0Fh/3J3Cv1bIH/f T1DV3BloDMzZOGVxoiRzw15Hxt0Vmaj5s/5RjeqseKajEY1S387oDO6H+YDSf1S1NPi/ pgzi9Nin6r6mJrVcS19Di5RVC+QkmwBE1UGEJBDMvM8cStCxP4D3SHykFny+8Ld6gKMx lKkgKJ4U4BNHjYLio/HFKZ3C3F+VekZ6PpCsh0d58NwvlaK4nmod/SXttTTClWX91jA5 Q0pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FxdVvwQo; 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 w4si7906989ilm.77.2021.07.15.11.53.24; Thu, 15 Jul 2021 11:53:37 -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=FxdVvwQo; 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 S231403AbhGOSx5 (ORCPT + 99 others); Thu, 15 Jul 2021 14:53:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:52374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240509AbhGOSuW (ORCPT ); Thu, 15 Jul 2021 14:50:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2CE2613DB; Thu, 15 Jul 2021 18:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374840; bh=kCdTWq7fWYA1GEGr+aSKfE6tn0rSyjfSV023TumUpz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxdVvwQoJ7+xIeQNJoM3eX+g5Ol5bA+oNr5XeRW4CZe6M0LPM1FR+x3/K+zBufPlm T0UDCFDwZfE5S92TTfh+XgBlIcswDTYtwnHA/iT8UPJRBNS+Y/qOiWxWyhu3+fD1uW ZC920FJcyeTzUQSFyTgph6Ms6tz8+XHB6SBhOg9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 047/215] drm/amd/display: Avoid HDCP over-read and corruption Date: Thu, 15 Jul 2021 20:36:59 +0200 Message-Id: <20210715182607.713417088@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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: Kees Cook [ Upstream commit 06888d571b513cbfc0b41949948def6cb81021b2 ] Instead of reading the desired 5 bytes of the actual target field, the code was reading 8. This could result in a corrupted value if the trailing 3 bytes were non-zero, so instead use an appropriately sized and zero-initialized bounce buffer, and read only 5 bytes before casting to u64. Signed-off-by: Kees Cook Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c index f244b72e74e0..53eab2b8e2c8 100644 --- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c +++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c @@ -29,8 +29,10 @@ static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp) { uint64_t n = 0; uint8_t count = 0; + u8 bksv[sizeof(n)] = { }; - memcpy(&n, hdcp->auth.msg.hdcp1.bksv, sizeof(uint64_t)); + memcpy(bksv, hdcp->auth.msg.hdcp1.bksv, sizeof(hdcp->auth.msg.hdcp1.bksv)); + n = *(uint64_t *)bksv; while (n) { count++; -- 2.30.2