drm/nouveau: fix ramht wraparound
Subsystems (3)
PATCH 1/1 drm/nouveau: fix ramht wraparound
When hash collision occurs and it's near ramht object boundary, we could read and possibly overwrite some memory after ramht object.
--- drivers/gpu/drm/nouveau/core/core/ramht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/core/ramht.c +1 -1
@@ -59,7 +59,7 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, } co +=8 ; -if (co >=nv_gpuobj (ramht)->size) +if (co +8 >nv_gpuobj (ramht)->size) co =0 ; }while (co != ho);
Signature · 1 line
1.8.0.2
A message that is not in the archive (sent off-list or not yet received): 1356043034-25739-5-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 14 lines · Marcin Slusarz
When hash collision occurs and it's near ramht object boundary, we could read and possibly overwrite some memory after ramht object.
Signed-off-by Marcin Slusarz <[email protected]>--- drivers/gpu/drm/nouveau/core/core/ramht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/core/core/ramht.c +0
-0
drivers/gpu/drm/nouveau/core/core/ramht.c nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, · line 62
Quoted 5 lines
drivers/gpu/drm/nouveau/core/core/ramht.c +1
-1@@ -59,7 +59,7 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, } co +=8 ; -if (co >=nv_gpuobj (ramht)->size) +if (co +8 >nv_gpuobj (ramht)->size)
I might just be really tired, but, how exactly is the original wrong? The original could even just be (co == size) and still work correctly as far as I can tell.
Ben.
Quoted 10 lines
drivers/gpu/drm/nouveau/core/core/ramht.c +0
-0co =0 ; }while (co != ho);Signature · 6 lines
1.8.0.2 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20121221001548.GA3839-6RkuLLNOGXsZ315U/[email protected]
Quoted 17 lines · Ben Skeggs
Quoted 16 lines · Marcin Slusarz
When hash collision occurs and it's near ramht object boundary, we could read and possibly overwrite some memory after ramht object.
Signed-off-by Marcin Slusarz <[email protected]>--- drivers/gpu/drm/nouveau/core/core/ramht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/core/core/ramht.c +0
-0@@ -59,7 +59,7 @@ nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, }
Quoted 6 lines
drivers/gpu/drm/nouveau/core/core/ramht.c nouveau_ramht_insert(struct nouveau_ramht *ramht, int chid, · line 62
Quoted 3 lines
drivers/gpu/drm/nouveau/core/core/ramht.c +1
-1co +=8 ; -if (co >=nv_gpuobj (ramht)->size) +if (co +8 >nv_gpuobj (ramht)->size)I might just be really tired, but, how exactly is the original wrong? The original could even just be (co == size) and still work correctly as far as I can tell.
Ah, crap, I didn't see that both hash value and ramht->size are divisible by 8. So original code is correct (although it relies on the above) and my version does not really fix anything.
Marcin