Skip to contentSkip to conversation

tests/gem_storedw_loop: Fix use after free for bufmgr

PATCH In review [email protected] 4 participants 6 messages Sep 22, 2015 – Sep 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/gem_storedw_loop: Fix use after free for bufmgr

From: Robert Beckett <[email protected]>

Move bufmgr destruction to end of tests. This avoids use after free on successive tests.

This could be squashed with the following patch to aid bisectability:

commit 0679702150157706a6def66b893b29c16345f4db

Author: Jesse Barnes <[email protected]>
Date:   Wed Aug 5 16:06:31 2015 -0700

tests/gem_storedw_loop: add new store_dword test to unify per-ring ones v2

---
 tests/gem_storedw_loop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_storedw_loop.c +1 -1
index 10b12d4..e7ebcc2 100644
@@ -128,7 +128,6 @@ store_test(int ring, int count)
 
 	drm_intel_bo_unreference(target_buffer);
 	intel_batchbuffer_free(batch);
-	drm_intel_bufmgr_destroy(bufmgr);
 }
 
 struct ring {
@@ -181,5 +180,6 @@ igt_main
 		}
 	}
 
+	drm_intel_bufmgr_destroy(bufmgr);
 	close(fd);
 }
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · On 09/22/2015 11:02 AM, [email protected] wrote:

From: Robert Beckett <[email protected]>

Move bufmgr destruction to end of tests. This avoids use after free on successive tests.

This could be squashed with the following patch to aid bisectability:

commit 0679702150157706a6def66b893b29c16345f4db

Author: Jesse Barnes <[email protected]>
Date:   Wed Aug 5 16:06:31 2015 -0700

tests/gem_storedw_loop: add new store_dword test to unify per-ring ones v2

---
 tests/gem_storedw_loop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_storedw_loop.c +0 -1
index 10b12d4..e7ebcc2 100644
@@ -128,7 +128,6 @@ store_test(int ring, int count)
 
 	drm_intel_bo_unreference(target_buffer);
 	intel_batchbuffer_free(batch);
-	drm_intel_bufmgr_destroy(bufmgr);
 }
 
 struct ring {

tests/gem_storedw_loop.c igt_main · line 185

Quoted 6 lines
tests/gem_storedw_loop.c +1 -0
@@ -181,5 +180,6 @@ igt_main
 		}
 	}
 
+	drm_intel_bufmgr_destroy(bufmgr);
 	close(fd);
 }

Looks good, thanks. Unfortunately too late to squash...

Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
Quoted 36 lines · Jesse Barnes
Quoted 35 lines · On 09/22/2015 11:02 AM, [email protected] wrote:

From: Robert Beckett <[email protected]>

Move bufmgr destruction to end of tests. This avoids use after free on successive tests.

This could be squashed with the following patch to aid bisectability:

commit 0679702150157706a6def66b893b29c16345f4db

Author: Jesse Barnes <[email protected]>
Date:   Wed Aug 5 16:06:31 2015 -0700

tests/gem_storedw_loop: add new store_dword test to unify per-ring ones v2

---
 tests/gem_storedw_loop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_storedw_loop.c +0 -1
index 10b12d4..e7ebcc2 100644
@@ -128,7 +128,6 @@ store_test(int ring, int count)
 
 	drm_intel_bo_unreference(target_buffer);
 	intel_batchbuffer_free(batch);
-	drm_intel_bufmgr_destroy(bufmgr);
 }
 
 struct ring {
@@ -181,5 +180,6 @@ igt_main
 		}
 	}
 
Quoted 8 lines

tests/gem_storedw_loop.c igt_main · line 185

Quoted 4 lines
tests/gem_storedw_loop.c +1 -0
+	drm_intel_bufmgr_destroy(bufmgr);
 	close(fd);
 }

Looks good, thanks. Unfortunately too late to squash...

No one from vpg has igt commit access so you need to push patches for them. I've done that now.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Jesse Barnes
Quoted 33 lines · On 09/22/2015 11:02 AM, [email protected] wrote:

From: Robert Beckett <[email protected]>

Move bufmgr destruction to end of tests. This avoids use after free on successive tests.

This could be squashed with the following patch to aid bisectability:

commit 0679702150157706a6def66b893b29c16345f4db

Author: Jesse Barnes <[email protected]>
Date:   Wed Aug 5 16:06:31 2015 -0700

tests/gem_storedw_loop: add new store_dword test to unify per-ring ones v2

---
 tests/gem_storedw_loop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_storedw_loop.c +0 -1
index 10b12d4..e7ebcc2 100644
@@ -128,7 +128,6 @@ store_test(int ring, int count)
 
    drm_intel_bo_unreference(target_buffer);
    intel_batchbuffer_free(batch);
-   drm_intel_bufmgr_destroy(bufmgr);
 }
 
 struct ring {

tests/gem_storedw_loop.c igt_main · line 185

Quoted 6 lines
tests/gem_storedw_loop.c +1 -0
@@ -181,5 +180,6 @@ igt_main
            }
    }
 
+   drm_intel_bufmgr_destroy(bufmgr);
    close(fd);
 }

Looks good, thanks. Unfortunately too late to squash...

Quoted 4 lines
Quoted 1 line

No one from vpg has igt commit access so you need to push patches for them. I've done that now.

Unfortunately this patch causes --list-subtest to fail, since the call to drm_intel_bufmgr_destroy is called with NULL which causes a segmentation fault. The calls to drm_intel_bufmgr_destroy and close should be in an igt_fixture block.

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH 1/1 gem_storedw_loop: fix segfault when listing subtests

Commit fb66cd5 (tests/gem_storedw_loop: Fix use after free for bufmgr) introduced a segmentation fault when listing subtests because drm_intel_bufmgr_destroy is called with NULL. Move this and the call to the close function inside an igt_fixture block to prevent them being called when listing subtests.

Cc Robert Beckett <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/gem_storedw_loop.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/gem_storedw_loop.c +4 -2
index e7ebcc2..e17e190 100644
@@ -180,6 +180,8 @@ igt_main
 		}
 	}
 
-	drm_intel_bufmgr_destroy(bufmgr);
-	close(fd);
+	igt_fixture {
+		drm_intel_bufmgr_destroy(bufmgr);
+		close(fd);
+	}
 }
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Acked-by on v1 1/1
#5 lore raw

Re: [PATCH i-g-t] gem_storedw_loop: fix segfault when listing subtests

Quoted 20 lines · Thomas Wood

Commit fb66cd5 (tests/gem_storedw_loop: Fix use after free for bufmgr) introduced a segmentation fault when listing subtests because drm_intel_bufmgr_destroy is called with NULL. Move this and the call to the close function inside an igt_fixture block to prevent them being called when listing subtests.

Cc Robert Beckett <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/gem_storedw_loop.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/gem_storedw_loop.c +0 -0
index e7ebcc2..e17e190 100644

tests/gem_storedw_loop.c igt_main · line 187

Quoted 10 lines
tests/gem_storedw_loop.c +4 -2
@@ -180,6 +180,8 @@ igt_main
 		}
 	}
 
-	drm_intel_bufmgr_destroy(bufmgr);
-	close(fd);
+	igt_fixture {
+		drm_intel_bufmgr_destroy(bufmgr);
+		close(fd);
+	}
 }

Um, yes. :) I won't pretend to know how the fixture stuff ought to work, so:

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx