linux/drivers/gpu/drm/amd/display/modules/hdcp
Harry Wentland 93c8fe6d56 drm/amd/display: guard against overflow in HDCP message dump
[Why]
mod_hdcp_dump_binary_message() computed target_size (a uint32_t) as roughly
byte_size * msg_size and gated the whole write on buf_size >= target_size. A
large msg_size can overflow target_size, wrapping it to a small value that
passes the check while the loop still writes byte_size * msg_size bytes
into buf. All current callers pass small constants so this is not reachable
today, but the unchecked arithmetic should be hardened.

[How]
Drop the overflow-prone target_size precomputation and instead bounds-check the
output position on every iteration, stopping once the next entry would not leave
room for the trailing terminator. This cannot overflow and, for oversized
messages, dumps as much as fits rather than printing nothing.

Fixes: 4c283fdac0 ("drm/amd/display: Add HDCP module")
Assisted-by: Copilot:claude-opus-4.8
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d0a775e5d70b376696245a14c09e3aa6dde0023a)
Cc: stable@vger.kernel.org
2026-07-01 13:00:40 -04:00
..
hdcp_ddc.c drm/amd/display: Clamp HDMI HDCP2 rx_id_list read to buffer size 2026-06-03 13:38:01 -04:00
hdcp_log.c drm/amd/display: guard against overflow in HDCP message dump 2026-07-01 13:00:40 -04:00
hdcp_log.h drm/amd/display: add additional hdcp traces 2025-10-20 18:24:53 -04:00
hdcp_psp.c drm/amd/display: Update HDCP and info_packet modules for FRL 2026-06-03 13:44:49 -04:00
hdcp_psp.h drm/amd/display: Update HDCP and info_packet modules for FRL 2026-06-03 13:44:49 -04:00
hdcp.c drm/amd/display: Update HDCP and info_packet modules for FRL 2026-06-03 13:44:49 -04:00
hdcp.h drm/amd/display: Update HDCP and info_packet modules for FRL 2026-06-03 13:44:49 -04:00
hdcp1_execution.c drm/amd/display: add additional hdcp traces 2025-10-20 18:24:53 -04:00
hdcp1_transition.c drm/amd/display: add authentication_complete in hdcp output 2021-08-09 15:43:33 -04:00
hdcp2_execution.c drm/amd/display: fw locality check refactors 2025-11-04 11:53:19 -05:00
hdcp2_transition.c drm/amd/display: fw locality check refactors 2025-11-04 11:53:19 -05:00
Makefile drm/amd/display: Add execution and transition states for HDCP2.2 2019-11-19 10:12:53 -05:00