Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp245578pxj; Tue, 1 Jun 2021 20:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+pUQYHmDfUcWoL9fZptZvHAhrFCjQz7J5mxVDKIVZxjDjIhQtFbXGVwB6j5suOGyotSP0 X-Received: by 2002:aa7:c1da:: with SMTP id d26mr27519318edp.92.1622605848670; Tue, 01 Jun 2021 20:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622605848; cv=none; d=google.com; s=arc-20160816; b=A4y9CTQe8cIbhLV1k+j9qlkla5FurjQvW7DJEbZ+5+6HkGTUQS59EQom3C+EDevGNo SVOIEewyq0k4rQXNI6/mj1tS+lyLJBIqQiMnNEQ6z6hYlr8M9lD8K8pObhBqbB1hVKgC lhOoF9vbrtrQDzN9vrxsoa6XT1VSu8rvz978+3wbYGBx7yxB80b5WL8IKMVthlUzglrB 9XFhDsecKYN3inErLTptNdB+giK+etsNg6fCE9WWfLeLU+uoMJJA8j2Dgbj3oIdkmC/E gEgPCvQ42IRCbd5fI5BoY1/fGPgMSn7hiAxZTiV0ZUwL/hqkSQYwFc+nxWKGst2xwX2r 1mGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aCCJ1eFEGcaWx0tMGwZOzk/m+ZOCXhNzKCETdM0irhY=; b=t0uLNOEQCAz5omzJX/bJpWCB2zJ1+JJnZJ5pK2LjpIIovWap8d1sM75Mu8nzfbpkSn MFe/V1ZOKJH5XsKi+k0QTE7I4b67+BXodtZvnynaTooV536Gp51Uz3nHyNprxGIMfNYL /ETscqzRepVFv96aXxJa3NgAUdHP6LNLzOIctwfso5cgsUynK+FfdcaHlfbracHHtqDn GeCtBsU5d13QxiDbH9xwZtf+hPwknaNwAG1A3EekzBdyPCy0edzPdaiKfeY6b6rq9D1t q1HG7VArN/fVz8Txo/sKP2DLvNWRC2IJCYAEass23SzNHGVSOCCwHds34nhNJso+2F2o 0+aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P+CxivsS; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si17410639eji.695.2021.06.01.20.50.25; Tue, 01 Jun 2021 20:50:48 -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=@gmail.com header.s=20161025 header.b=P+CxivsS; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbhFBCIJ (ORCPT + 99 others); Tue, 1 Jun 2021 22:08:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhFBCIG (ORCPT ); Tue, 1 Jun 2021 22:08:06 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B64C061574 for ; Tue, 1 Jun 2021 19:06:23 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id t10-20020a05683022eab0290304ed8bc759so1100466otc.12 for ; Tue, 01 Jun 2021 19:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aCCJ1eFEGcaWx0tMGwZOzk/m+ZOCXhNzKCETdM0irhY=; b=P+CxivsSP2vTyBnLPSJf2UT7S3Vq3UDgbdZmYKTVt14drvzbGjdJeG/9pIdzwmMPV7 J4v6+F13KjldLM5urdVgSSxpyJDvEL7iV4cS3KmurqhIR6Y6EOJPTSS6NFIYqCz7S6g2 nC1Wy0ESwhQmb5uAu2anv8IhUfEeQoJuCETATK/PUf9gd4Ti8/sgsbwEvCezk0dvcPXU jTNEtJbLQwOmLEGTPDOFB0QEGtcWY5ZnebZwEIMYmB4Uesq1t3O/aDSVAW9lIbkNw7QH ZtvsrBEPqPH6HGeXFY1fRr9afwdBSeqCEIu00WQifkpbReliFlcejkEjNC4HnIAnxSxL nhFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aCCJ1eFEGcaWx0tMGwZOzk/m+ZOCXhNzKCETdM0irhY=; b=HL55VRLEZjh1qsNAcOcmBUaS8/9Q0tqDjf4nvP/wppbJeEnAgdJILX8mReaMnQiCXd HDE47X5zWVK6uH/2O2uiz6dU4X7bhSwUbsY1Ki8aRUEb0YEzHSM/5LUNTX6tfyIiqBhO IT2QFkcxEcoBKhDEjtVpaIgDdxRpjr/NxaGcA/IOmL8KFTCxDtPSFf6T3N2hPQeduz5J ETHV6hD+iHFoY2gCD/Dkw71k+TZdKS9hUKVpO1T6L6YurvK92A2rd4Ps9hipR23GBWxd cNlQfLloKycpSDAkMZJSUvnXAHQk3RCuH9rGFD3tz0dA4QZ56AhZRI7eepZ7PbCnpmk4 D6uA== X-Gm-Message-State: AOAM53110wgUt53fBy7skLzKu/hPF5NxXcl+W3hZtXjR3vTnBc8cArKd 17Vurri5e1Be+5g1UKTJrIxDW7oYZuuxes3iesI= X-Received: by 2002:a9d:57cd:: with SMTP id q13mr24131409oti.23.1622599582693; Tue, 01 Jun 2021 19:06:22 -0700 (PDT) MIME-Version: 1.0 References: <20210528175354.790719-1-keescook@chromium.org> In-Reply-To: <20210528175354.790719-1-keescook@chromium.org> From: Alex Deucher Date: Tue, 1 Jun 2021 22:06:11 -0400 Message-ID: Subject: Re: [PATCH] drm/amd/display: Avoid HDCP over-read and corruption To: Kees Cook Cc: Alex Deucher , Martin Tsai , Leo Li , LKML , Wenjing Liu , Anson Jacob , amd-gfx list , Nicholas Kazlauskas , David Airlie , Daniel Wheeler , Maling list - DRI developers , =?UTF-8?Q?Christian_K=C3=B6nig?= , Bindu Ramamurthy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 28, 2021 at 1:54 PM Kees Cook wrote: > > 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 Applied. Thanks! > --- > 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 2cbd931363bd..6d26d9c63ab2 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.25.1 >