linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: drm/amd/display: Add HDCP module - static analysis bug report
@ 2019-10-03 22:08 Colin Ian King
  2019-10-09 16:32 ` Daniel Vetter
  0 siblings, 1 reply; 18+ messages in thread
From: Colin Ian King @ 2019-10-03 22:08 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter,
	amd-gfx mailing list, dri-devel, Bhawanpreet Lakha
  Cc: linux-kernel

Hi,

Static analysis with Coverity has detected a potential issue with
function validate_bksv in
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c with recent
commit:

commit ed9d8e2bcb003ec94658cafe9b1bb3960e2139ec
Author: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Date:   Tue Aug 6 17:52:01 2019 -0400

    drm/amd/display: Add HDCP module


The analysis is as follows:

 28 static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp)
 29 {

CID 89852 (#1 of 1): Out-of-bounds read (OVERRUN)

1. overrun-local:
Overrunning array of 5 bytes at byte offset 7 by dereferencing pointer
(uint64_t *)hdcp->auth.msg.hdcp1.bksv.

 30        uint64_t n = *(uint64_t *)hdcp->auth.msg.hdcp1.bksv;
 31        uint8_t count = 0;
 32
 33        while (n) {
 34                count++;
 35                n &= (n - 1);
 36        }

hdcp->auth.msg.hdcp1.bksv is an array of 5 uint8_t as defined in
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h as follows:

struct mod_hdcp_message_hdcp1 {
        uint8_t         an[8];
        uint8_t         aksv[5];
        uint8_t         ainfo;
        uint8_t         bksv[5];
        uint16_t        r0p;
        uint8_t         bcaps;
        uint16_t        bstatus;
        uint8_t         ksvlist[635];
        uint16_t        ksvlist_size;
        uint8_t         vp[20];

        uint16_t        binfo_dp;
};

variable n is going to contain the contains of r0p and bcaps. I'm not
sure if that is intentional. If not, then the count is going to be
incorrect if these are non-zero.

Colin

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-11-05 15:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 22:08 drm/amd/display: Add HDCP module - static analysis bug report Colin Ian King
2019-10-09 16:32 ` Daniel Vetter
2019-10-09 18:23   ` Lakha, Bhawanpreet
2019-10-09 18:43     ` Daniel Vetter
2019-10-09 20:46       ` Lakha, Bhawanpreet
2019-10-09 20:58         ` Daniel Vetter
2019-11-04 10:53           ` Daniel Vetter
2019-11-04 15:23             ` Harry Wentland
2019-11-04 16:05               ` Lakha, Bhawanpreet
2019-11-04 16:54               ` Daniel Vetter
2019-11-04 17:05                 ` Alex Deucher
2019-11-04 17:24                   ` Daniel Vetter
2019-11-05 12:51                     ` Alex Deucher
2019-11-05 13:14                       ` Daniel Vetter
2019-11-05 14:17                         ` Harry Wentland
2019-11-05 14:23                           ` Daniel Vetter
2019-11-05 14:39                             ` Harry Wentland
2019-11-05 15:00                               ` Daniel Vetter

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).