Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/intel_blt.c: ensure uint64_t result of multiplication
@ 2023-10-17 14:36 Marcin Bernatowicz
  2023-10-17 15:59 ` [igt-dev] ✗ CI.xeBAT: failure for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Marcin Bernatowicz @ 2023-10-17 14:36 UTC (permalink / raw)
  To: igt-dev

Additionally check for overflow.

This should allow to exercise large buffers
ex. xe_exercise_blt -W 16384 -H 16384

Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
 lib/intel_blt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/intel_blt.c b/lib/intel_blt.c
index a76c7a404..f46c85e91 100644
--- a/lib/intel_blt.c
+++ b/lib/intel_blt.c
@@ -1607,12 +1607,18 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
 		  bool create_mapping)
 {
 	struct blt_copy_object *obj;
-	uint64_t size = width * height * bpp / 8;
 	uint32_t stride = tiling == T_LINEAR ? width * 4 : width;
 	uint32_t handle;
+	uint64_t size;
 
 	igt_assert_f(blt->driver, "Driver isn't set, have you called blt_copy_init()?\n");
 
+	igt_assert_f((UINT64_MAX / 8) >= width &&
+		     (UINT64_MAX / width) >= height &&
+		     (UINT64_MAX / (width * height)) >= bpp, "Overflow detected!\n");
+
+	size = (uint64_t)width * height * bpp / 8;
+
 	obj = calloc(1, sizeof(*obj));
 
 	obj->size = size;
-- 
2.42.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-20  6:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17 14:36 [igt-dev] [PATCH i-g-t] lib/intel_blt.c: ensure uint64_t result of multiplication Marcin Bernatowicz
2023-10-17 15:59 ` [igt-dev] ✗ CI.xeBAT: failure for " Patchwork
2023-10-17 16:00 ` [igt-dev] ✗ Fi.CI.BAT: " Patchwork
2023-10-18  9:08 ` [igt-dev] [PATCH i-g-t] " Karolina Stolarek
2023-10-19 14:41   ` Bernatowicz, Marcin
2023-10-20  6:58     ` Karolina Stolarek
2023-10-18 15:28 ` Kamil Konieczny
2023-10-19 15:23   ` Bernatowicz, Marcin
2023-10-19 15:27   ` Kamil Konieczny
2023-10-19 15:36     ` Bernatowicz, Marcin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox