Skip to content

Commit 58556dc

Browse files
superm1gregkh
authored andcommitted
drm/amd: Guard against bad data for ATIF ACPI method
commit bf58f03 upstream. If a BIOS provides bad data in response to an ATIF method call this causes a NULL pointer dereference in the caller. ``` ? show_regs (arch/x86/kernel/dumpstack.c:478 (discriminator 1)) ? __die (arch/x86/kernel/dumpstack.c:423 arch/x86/kernel/dumpstack.c:434) ? page_fault_oops (arch/x86/mm/fault.c:544 (discriminator 2) arch/x86/mm/fault.c:705 (discriminator 2)) ? do_user_addr_fault (arch/x86/mm/fault.c:440 (discriminator 1) arch/x86/mm/fault.c:1232 (discriminator 1)) ? acpi_ut_update_object_reference (drivers/acpi/acpica/utdelete.c:642) ? exc_page_fault (arch/x86/mm/fault.c:1542) ? asm_exc_page_fault (./arch/x86/include/asm/idtentry.h:623) ? amdgpu_atif_query_backlight_caps.constprop.0 (drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:387 (discriminator 2)) amdgpu ? amdgpu_atif_query_backlight_caps.constprop.0 (drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:386 (discriminator 1)) amdgpu ``` It has been encountered on at least one system, so guard for it. Fixes: d38ceaf ("drm/amdgpu: add core driver (v4)") Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit c9b7c80) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 89a4a73 commit 58556dc

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
9090
struct acpi_buffer *params)
9191
{
9292
acpi_status status;
93+
union acpi_object *obj;
9394
union acpi_object atif_arg_elements[2];
9495
struct acpi_object_list atif_arg;
9596
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -112,16 +113,24 @@ static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
112113

113114
status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
114115
&buffer);
116+
obj = (union acpi_object *)buffer.pointer;
115117

116-
/* Fail only if calling the method fails and ATIF is supported */
118+
/* Fail if calling the method fails and ATIF is supported */
117119
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
118120
DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
119121
acpi_format_exception(status));
120-
kfree(buffer.pointer);
122+
kfree(obj);
121123
return NULL;
122124
}
123125

124-
return buffer.pointer;
126+
if (obj->type != ACPI_TYPE_BUFFER) {
127+
DRM_DEBUG_DRIVER("bad object returned from ATIF: %d\n",
128+
obj->type);
129+
kfree(obj);
130+
return NULL;
131+
}
132+
133+
return obj;
125134
}
126135

127136
/**

0 commit comments

Comments
 (0)