* [PATCH] drm/amd/display: Avoid HDCP over-read and corruption
@ 2021-05-28 17:53 Kees Cook
2021-06-02 2:06 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2021-05-28 17:53 UTC (permalink / raw)
To: Alex Deucher
Cc: Martin Tsai, Kees Cook, Leo Li, linux-kernel, Wenjing Liu,
Anson Jacob, amd-gfx, Nicholas Kazlauskas, David Airlie,
Daniel Wheeler, dri-devel, Christian König,
Bindu Ramamurthy
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amd/display: Avoid HDCP over-read and corruption
2021-05-28 17:53 [PATCH] drm/amd/display: Avoid HDCP over-read and corruption Kees Cook
@ 2021-06-02 2:06 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2021-06-02 2:06 UTC (permalink / raw)
To: Kees Cook
Cc: Martin Tsai, Leo Li, David Airlie, Wenjing Liu, LKML,
amd-gfx list, Christian König, Anson Jacob, Daniel Wheeler,
Maling list - DRI developers, Alex Deucher, Nicholas Kazlauskas,
Bindu Ramamurthy
On Fri, May 28, 2021 at 1:54 PM Kees Cook <keescook@chromium.org> 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 <keescook@chromium.org>
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-02 2:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 17:53 [PATCH] drm/amd/display: Avoid HDCP over-read and corruption Kees Cook
2021-06-02 2:06 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).