aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-05-28 10:53:54 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-19 09:44:45 +0200
commitc5b518f4b98dbb2bc31b6a55e6aaa1e0e2948f2e (patch)
treee06ddbc8c93e59b58d5879d830e314dade1ee8c0
parent3c172f6e444bad7e1967021c86d9b7de9def5199 (diff)
downloadkernel_replicant_linux-c5b518f4b98dbb2bc31b6a55e6aaa1e0e2948f2e.tar.gz
kernel_replicant_linux-c5b518f4b98dbb2bc31b6a55e6aaa1e0e2948f2e.tar.bz2
kernel_replicant_linux-c5b518f4b98dbb2bc31b6a55e6aaa1e0e2948f2e.zip
drm/amd/display: Avoid HDCP over-read and corruption
[ 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 <keescook@chromium.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c4
1 files changed, 3 insertions, 1 deletions
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++;