drm: Fix possible UAF in drm_addmap_core
Subsystems (2)
PATCH 1/1 drm: Fix possible UAF in drm_addmap_core
smatch report warning as follows:
drivers/gpu/drm/drm_bufs.c:365 drm_addmap_core() warn:
'&list->head' not removed from list
If drm_map_handle() fails in drm_addmap_core(), the list will be freed, but the list->head will not be removed from dev->maplist, then list traversal may cause UAF.
Fix by removeing it from list->head before free().
Fixes 9a298b2acd77 ("drm: Remove memory debugging infrastructure.")
Signed-off-by Yi Yang <[email protected]>
--- drivers/gpu/drm/drm_bufs.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_bufs.c +1 -0
@@ -362,6 +362,7 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,if (map->type == _DRM_REGISTERS)iounmap (map->handle);kfree (map); +list_del (&list->head);kfree (list);mutex_unlock (&dev->struct_mutex);return ret;
Signature · 1 line
2.17.1