mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-08 18:13:59 +02:00
drm/amd/display: Reject gpio_bitshift >= 32 in bios_parser_get_gpio_pin_info()
commit49c3da6596upstream. [Why & How] gpio_bitshift is a uint8_t read directly from the VBIOS GPIO pin table. If the value is >= 32, the expression "1 << gpio_bitshift" triggers undefined behaviour in C (shift count exceeds type width). On x86 the shift is silently masked to 5 bits, producing an incorrect GPIO mask that may cause wrong MMIO register bits to be toggled. Validate gpio_bitshift before use and return BP_RESULT_BADBIOSTABLE for out-of-range values. Fixes:ae79c310b1("drm/amd/display: Add DCE12 bios parser support") Assisted-by: Copilot:claude-opus-4.6 Reviewed-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Ray Wu <ray.wu@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commiteadf438ab8) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
92ad2d7f80
commit
930ec42d00
@@ -546,8 +546,10 @@ static enum bp_result bios_parser_get_gpio_pin_info(
|
||||
info->offset_en = info->offset + 1;
|
||||
info->offset_mask = info->offset - 1;
|
||||
|
||||
info->mask = (uint32_t) (1 <<
|
||||
header->gpio_pin[i].gpio_bitshift);
|
||||
if (header->gpio_pin[i].gpio_bitshift >= 32)
|
||||
return BP_RESULT_BADBIOSTABLE;
|
||||
|
||||
info->mask = 1u << header->gpio_pin[i].gpio_bitshift;
|
||||
info->mask_y = info->mask + 2;
|
||||
info->mask_en = info->mask + 1;
|
||||
info->mask_mask = info->mask - 1;
|
||||
|
||||
Reference in New Issue
Block a user