Skip to contentSkip to conversation

drm/komeda: Fix bit check to import to value of proper type

PATCH In review [email protected] 2 participants 2 messages Dec 18, 2020

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

PATCH 1/1 drm/komeda: Fix bit check to import to value of proper type

From: Carsten Haitzler <[email protected]>

KASAN found this problem. find_first_bit() expects to look at a pointer pointing to a long, but we look at a u32 - this is going to be an issue with endianess but, KSAN already flags this as out-of-bounds stack reads. This fixes it by just importing inot a local long.

---
 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +2 -1
index 452e505a1fd3..719a79728e24 100644
@@ -137,9 +137,10 @@ komeda_pipeline_get_first_component(struct komeda_pipeline *pipe,
 				    u32 comp_mask)
 {
 	struct komeda_component *c = NULL;
+	unsigned long comp_mask_local = (unsigned long)comp_mask;
 	int id;
 
-	id = find_first_bit((unsigned long *)&comp_mask, 32);
+	id = find_first_bit(&comp_mask_local, 32);
 	if (id < 32)
 		c = komeda_pipeline_get_component(pipe, id);
 
Signature · 6 lines
2.29.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Fri, Dec 18, 2020 at 03:08:12PM +0000, [email protected] wrote:

From: Carsten Haitzler <[email protected]>

KASAN found this problem. find_first_bit() expects to look at a pointer pointing to a long, but we look at a u32 - this is going to be an issue with endianess but, KSAN already flags this as out-of-bounds stack reads. This fixes it by just importing inot a local long.

Best regards,
Liviu

Quoted 23 lines
---
 drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +2 -1
index 452e505a1fd3..719a79728e24 100644
@@ -137,9 +137,10 @@ komeda_pipeline_get_first_component(struct komeda_pipeline *pipe,
 				    u32 comp_mask)
 {
 	struct komeda_component *c = NULL;
+	unsigned long comp_mask_local = (unsigned long)comp_mask;
 	int id;
 
-	id = find_first_bit((unsigned long *)&comp_mask, 32);
+	id = find_first_bit(&comp_mask_local, 32);
 	if (id < 32)
 		c = komeda_pipeline_get_component(pipe, id);
 
Signature · 1 line
2.29.2
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel