linux/drivers/gpu/drm/amd/display/modules
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
..
color drm/amd/display: Fix multiple compiler warnings 2026-05-11 16:10:30 -04:00
freesync drm/amd/display: Fix implicit narrowing conversions in modules 2026-04-17 15:21:29 -04:00
hdcp drm/amd/display: guard against overflow in HDCP message dump 2026-07-01 13:00:40 -04:00
inc drm/amd/display: Update HDCP and info_packet modules for FRL 2026-06-03 13:44:49 -04:00
info_packet drm/amd/display: Add missing kdoc for ALLM parameters 2026-06-03 13:45:53 -04:00
power drm/amd/display: Handle aux_inst for connectors without DDC pin 2026-06-03 13:43:42 -04:00
vmid drm/amd/display: Fix type mismatches in DC and DMUB modules 2026-05-05 09:56:52 -04:00