Skip to contentSkip to conversation

drm/i915: Reject garbage in unsed ctx create/destroy fields

PATCH In review Daniel Vetter 4 participants 4 messages Feb 11, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Reject garbage in unsed ctx create/destroy fields

Forgotten ever since, but luckily we're at least good at memset.

Testecase: igt/gem_ctx_create/invalid-pad
Testecase: igt/gem_ctx_bad_destroy/invalid-pad

---
 drivers/gpu/drm/i915/i915_gem_context.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_gem_context.c +10 -0
index 8603bf48d3ee..378011e4704d 100644
@@ -748,6 +748,11 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	struct intel_context *ctx;
 	int ret;
 
+	if (args->pad) {
+		DRM_DEBUG_DRIVER("garbage in pad 0x%08x\n", args->pad);
+		return -EINVAL;
+	}
+
 	if (!contexts_enabled(dev))
 		return -ENODEV;
 
@@ -774,6 +779,11 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 	struct intel_context *ctx;
 	int ret;
 
+	if (args->pad) {
+		DRM_DEBUG_DRIVER("garbage in pad 0x%08x\n", args->pad);
+		return -EINVAL;
+	}
+
 	if (args->ctx_id == DEFAULT_CONTEXT_HANDLE)
 		return -ENOENT;
 
Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 5 lines · Daniel Vetter

Forgotten ever since, but luckily we're at least good at memset.

Testecase: igt/gem_ctx_create/invalid-pad
Testecase: igt/gem_ctx_bad_destroy/invalid-pad

I wonder if we used mbz instead of pad, we would have a slightly more obvious reminder to zero the fields.

Looks like pad is only cleared fortuituosly in current userspace though. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 11 lines · Chris Wilson
Quoted 5 lines · Daniel Vetter

Forgotten ever since, but luckily we're at least good at memset.

Testecase: igt/gem_ctx_create/invalid-pad
Testecase: igt/gem_ctx_bad_destroy/invalid-pad

I wonder if we used mbz instead of pad, we would have a slightly more obvious reminder to zero the fields.

Looks like pad is only cleared fortuituosly in current userspace though.

Oops, VG_CLEAR isn't as good as I've thought. Time to write more patches I guess. But I expect that most compile libdrm with valgrind support, so I still think we could try this out for 3.21 and see what happens ... -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tested-by on v1 1/1
#3 lore raw
In reply to Daniel Vetter

Task id: 5757 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV -1 281/281 280/281
ILK 313/313 313/313

SNB                 -3              309/322              306/322
IVB                 -3              380/380              377/380
BYT                 -3              296/296              293/296
HSW                 -3              426/426              423/426
BDW                 -4              318/318              314/318
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
*PNV  igt_gen3_render_mixed_blits      PASS(2, M23)      CRASH(1, M23)
*SNB  igt_gem_ctx_basic      PASS(2, M22)      NSPT(1, M22)
*SNB  igt_gem_ctx_create      PASS(2, M22)      NSPT(1, M22)
*SNB  igt_gem_ctx_exec_basic      PASS(2, M22)      FAIL(1, M22)
*IVB  igt_gem_ctx_basic      PASS(2, M21)      NSPT(1, M21)
*IVB  igt_gem_ctx_create      PASS(2, M21)      NSPT(1, M21)
*IVB  igt_gem_ctx_exec_basic      PASS(2, M21)      FAIL(1, M21)
*BYT  igt_gem_ctx_basic      PASS(2, M50)      NSPT(1, M50)
*BYT  igt_gem_ctx_create      PASS(2, M50)      NSPT(1, M50)
*BYT  igt_gem_ctx_exec_basic      PASS(2, M50)      FAIL(1, M50)
*HSW  igt_gem_ctx_basic      PASS(2, M20)      NSPT(1, M20)
*HSW  igt_gem_ctx_create      PASS(2, M20)      NSPT(1, M20)
*HSW  igt_gem_ctx_exec_basic      PASS(2, M20)      FAIL(1, M20)
*BDW  igt_gem_ctx_basic      PASS(2, M30)      NSPT(1, M30)
*BDW  igt_gem_ctx_create      PASS(2, M30)      NSPT(1, M30)
*BDW  igt_gem_ctx_exec_basic      PASS(2, M30)      FAIL(1, M30)
*BDW  igt_gem_gtt_hog      PASS(2, M30)      DMESG_WARN(1, M30)

Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx