amdgpu: Don't dereference device_handle after amdgpu_device_deinitialize
PATCH 1/3 amdgpu: Don't dereference device_handle after amdgpu_device_deinitialize
From: Michel Dänzer <[email protected]>
Fixes use after free:
==2537== Invalid read of size 4
==2537== at 0x1162C9: suite_deadlock_tests_enable (deadlock_tests.c:101) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560) ==2537== Address 0x5e44f24 is 452 bytes inside a block of size 1,016 free'd ==2537== at 0x4C2BE1B: free (vg_replace_malloc.c:530) ==2537== by 0x504CD8B: amdgpu_device_reference (amdgpu_device.c:164) ==2537== by 0x504CD8B: amdgpu_device_deinitialize (amdgpu_device.c:307) ==2537== by 0x1162BB: suite_deadlock_tests_enable (deadlock_tests.c:97) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560) ==2537== Block was alloc'd at ==2537== at 0x4C2CC05: calloc (vg_replace_malloc.c:711) ==2537== by 0x504CA5E: amdgpu_device_initialize (amdgpu_device.c:212) ==2537== by 0x116298: suite_deadlock_tests_enable (deadlock_tests.c:93) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560)
--- tests/amdgpu/deadlock_tests.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
tests/amdgpu/deadlock_tests.c +7 -6
@@ -90,20 +90,21 @@ static void amdgpu_deadlock_compute(void);CU_BOOL suite_deadlock_tests_enable (void ) { +CU_BOOL enable =CU_TRUE ; +if (amdgpu_device_initialize (drm_amdgpu[0 ], &major_version, &minor_version, &device_handle))return CU_FALSE ; -if (amdgpu_device_deinitialize (device_handle)) -return CU_FALSE ; - -if (device_handle->info.family_id ==AMDGPU_FAMILY_AI ) {printf ("\n\nCurrently hangs the CP on this ASIC, deadlock suite disabled\n" ); -return CU_FALSE ; + enable =CU_FALSE ; } -return CU_TRUE ; +if (amdgpu_device_deinitialize (device_handle)) +return CU_FALSE ; + +return enable; }int suite_deadlock_tests_init (void )
Signature · 6 lines
2.15.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180117112445.2582-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
PATCH 2/3 amdgpu: Disable deadlock test suite by default for SI ASICs
From: Michel Dänzer <[email protected]>
Hangs my Cape Verde.
--- tests/amdgpu/deadlock_tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/amdgpu/deadlock_tests.c +2 -1
@@ -96,7 +96,8 @@ CU_BOOL suite_deadlock_tests_enable(void) &minor_version, &device_handle))return CU_FALSE ; -if (device_handle->info.family_id ==AMDGPU_FAMILY_AI ) { +if (device_handle->info.family_id ==AMDGPU_FAMILY_AI || + device_handle->info.family_id ==AMDGPU_FAMILY_SI ) {printf ("\n\nCurrently hangs the CP on this ASIC, deadlock suite disabled\n" ); enable =CU_FALSE ; }
Signature · 6 lines
2.15.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 amdgpu: Disable VM test suite by default for SI ASICs
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Hangs my Cape Verde.
--- tests/amdgpu/amdgpu_test.c | 2 +- tests/amdgpu/amdgpu_test.h | 5 +++++ tests/amdgpu/vm_tests.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
tests/amdgpu/amdgpu_test.c +1 -1
@@ -167,7 +167,7 @@ static Suites_Active_Status suites_active_stat[] = { }, { .pName = VM_TESTS_STR, - .pActive = always_active, + .pActive = suite_vm_tests_enable, }, };
tests/amdgpu/amdgpu_test.h +5 -0
@@ -184,6 +184,11 @@ int suite_vm_tests_init();*/ int suite_vm_tests_clean (); +/** +* Decide if the suite is enabled by default or not. +*/ +CU_BOOL suite_vm_tests_enable (void ); +/** * Tests in vm test suite */
tests/amdgpu/vm_tests.c +20 -0
@@ -25,6 +25,7 @@#include "amdgpu_test.h" #include "amdgpu_drm.h" +#include "amdgpu_internal.h" static amdgpu_device_handle device_handle;static uint32_t major_version;
@@ -33,6 +34,25 @@ static uint32_t minor_version;static void amdgpu_vmid_reserve_test (void ); +CU_BOOL suite_vm_tests_enable (void ) +{ +CU_BOOL enable =CU_TRUE ; + +if (amdgpu_device_initialize (drm_amdgpu[0 ], &major_version, + &minor_version, &device_handle)) +return CU_FALSE ; + +if (device_handle->info.family_id ==AMDGPU_FAMILY_SI ) { +printf ("\n\nCurrently hangs the CP on this ASIC, VM suite disabled\n" ); + enable =CU_FALSE ; + } + +if (amdgpu_device_deinitialize (device_handle)) +return CU_FALSE ; + +return enable; +} +int suite_vm_tests_init (void ) {struct amdgpu_gpu_info gpu_info = {0 };
Signature · 6 lines
2.15.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
Reviewed-byAm 17.01.2018 um 12:24 schrieb Michel Dänzer:
Quoted 22 lines
From: Michel Dänzer <[email protected]>
Fixes use after free:
==2537== Invalid read of size 4
==2537== at 0x1162C9: suite_deadlock_tests_enable (deadlock_tests.c:101) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560) ==2537== Address 0x5e44f24 is 452 bytes inside a block of size 1,016 free'd ==2537== at 0x4C2BE1B: free (vg_replace_malloc.c:530) ==2537== by 0x504CD8B: amdgpu_device_reference (amdgpu_device.c:164) ==2537== by 0x504CD8B: amdgpu_device_deinitialize (amdgpu_device.c:307) ==2537== by 0x1162BB: suite_deadlock_tests_enable (deadlock_tests.c:97) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560) ==2537== Block was alloc'd at ==2537== at 0x4C2CC05: calloc (vg_replace_malloc.c:711) ==2537== by 0x504CA5E: amdgpu_device_initialize (amdgpu_device.c:212) ==2537== by 0x116298: suite_deadlock_tests_enable (deadlock_tests.c:93) ==2537== by 0x10B157: amdgpu_disable_suits (amdgpu_test.c:421) ==2537== by 0x10B157: main (amdgpu_test.c:560)
Quoted 1 line
Signed-off-by Michel Dänzer <[email protected]>
And Acked-by: Christian König <[email protected]> for the other two in the series.
Regards,
Christian.
Quoted 26 lines
--- tests/amdgpu/deadlock_tests.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)tests/amdgpu/deadlock_tests.c +3
-5@@ -90,20 +90,21 @@ static void amdgpu_deadlock_compute(void);CU_BOOL suite_deadlock_tests_enable (void ) { +CU_BOOL enable =CU_TRUE ; +if (amdgpu_device_initialize (drm_amdgpu[0 ], &major_version, &minor_version, &device_handle))return CU_FALSE ; -if (amdgpu_device_deinitialize (device_handle)) -return CU_FALSE ; - -if (device_handle->info.family_id ==AMDGPU_FAMILY_AI ) {printf ("\n\nCurrently hangs the CP on this ASIC, deadlock suite disabled\n" ); -return CU_FALSE ; + enable =CU_FALSE ;
tests/amdgpu/deadlock_tests.c static void amdgpu_deadlock_compute(void); · line 110
Quoted 10 lines
tests/amdgpu/deadlock_tests.c +4
-1} -return CU_TRUE ; +if (amdgpu_device_deinitialize (device_handle)) +return CU_FALSE ; + +return enable; }int suite_deadlock_tests_init (void )
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx