[igt-dev] [PATCH i-g-t 5/6] tests/kms_invalid_mode: Test clock==(U)INT_MAX

Ville Syrjala ville.syrjala at linux.intel.com
Thu Sep 16 15:35:14 UTC 2021


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Test against some big clock values to make sure we can't trick the
kernel into bypassing the validation via an integer overflows/etc.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/i915/kms_invalid_mode.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/i915/kms_invalid_mode.c b/tests/i915/kms_invalid_mode.c
index 6d56a378d141..722aa816fca1 100644
--- a/tests/i915/kms_invalid_mode.c
+++ b/tests/i915/kms_invalid_mode.c
@@ -23,6 +23,7 @@
  */
 
 #include "igt.h"
+#include <limits.h>
 #include <stdbool.h>
 
 IGT_TEST_DESCRIPTION("Make sure all modesets are rejected when the requested mode is invalid");
@@ -107,6 +108,20 @@ adjust_mode_zero_clock(data_t *data, drmModeModeInfoPtr mode)
 	return true;
 }
 
+static bool
+adjust_mode_int_max_clock(data_t *data, drmModeModeInfoPtr mode)
+{
+	mode->clock = INT_MAX;
+	return true;
+}
+
+static bool
+adjust_mode_uint_max_clock(data_t *data, drmModeModeInfoPtr mode)
+{
+	mode->clock = UINT_MAX;
+	return true;
+}
+
 static bool
 adjust_mode_zero_hdisplay(data_t *data, drmModeModeInfoPtr mode)
 {
@@ -244,6 +259,12 @@ static const struct {
 	{ .name = "zero-clock",
 	  .adjust_mode = adjust_mode_zero_clock,
 	},
+	{ .name = "int-max-clock",
+	  .adjust_mode = adjust_mode_int_max_clock,
+	},
+	{ .name = "uint-max-clock",
+	  .adjust_mode = adjust_mode_uint_max_clock,
+	},
 	{ .name = "zero-hdisplay",
 	  .adjust_mode = adjust_mode_zero_hdisplay,
 	},
-- 
2.32.0



More information about the igt-dev mailing list