gpu/xen: Fix a use after free in xen_drm_drv_init
Subsystems (3)
PATCH 1/1 gpu/xen: Fix a use after free in xen_drm_drv_init
In function displback_changed, has the call chain displback_connect(front_info)->xen_drm_drv_init(front_info). We can see that drm_info is assigned to front_info->drm_info and drm_info is freed in fail branch in xen_drm_drv_init().
Later displback_disconnect(front_info) is called and it calls xen_drm_drv_fini(front_info) cause a use after free by drm_info = front_info->drm_info statement.
My patch has done two things. First fixes the fail label which drm_info = kzalloc() failed and still free the drm_info. Second sets front_info->drm_info to NULL to avoid uaf.
--- drivers/gpu/drm/xen/xen_drm_front.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/xen/xen_drm_front.c +4 -2
@@ -521,7 +521,7 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info) drm_dev =drm_dev_alloc (&xen_drm_driver, dev);if (IS_ERR (drm_dev)) { ret =PTR_ERR (drm_dev); - goto fail; + goto fail_dev; } drm_info->drm_dev = drm_dev;
@@ -551,8 +551,10 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info)drm_kms_helper_poll_fini (drm_dev);drm_mode_config_cleanup (drm_dev);drm_dev_put (drm_dev); -fail: +fail_dev:kfree (drm_info); + front_info->drm_info =NULL ; +fail:return ret; }
Signature · 1 line
2.25.1
Hi,
good catch
Quoted 9 lines · Lv Yunlong
In function
displback_changed, has the call chain displback_connect(front_info)->xen_drm_drv_init(front_info). We can see thatdrm_infois assigned tofront_info->drm_infoanddrm_infois freed in fail branch inxen_drm_drv_init().Later
displback_disconnect(front_info)is called and it callsxen_drm_drv_fini(front_info)cause a use after free bydrm_info=front_info->drm_infostatement.
Quoted 5 lines
My patch has done two things. First fixes the fail label which
drm_info=kzalloc()failed and still free thedrm_info. Second setsfront_info->drm_infoto NULL to avoid uaf.Signed-off-by Lv Yunlong <[email protected]>
Thank you for the patch,
Will apply to drm-misc-next-fixes
Thank you,
Oleksandr
Quoted 19 lines
--- drivers/gpu/drm/xen/xen_drm_front.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/xen/xen_drm_front.c +1
-1@@ -521,7 +521,7 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info) drm_dev =drm_dev_alloc (&xen_drm_driver, dev);if (IS_ERR (drm_dev)) { ret =PTR_ERR (drm_dev); - goto fail; + goto fail_dev; } drm_info->drm_dev = drm_dev;@@ -551,8 +551,10 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info)drm_kms_helper_poll_fini (drm_dev);
drivers/gpu/drm/xen/xen_drm_front.c static int xen_drm_drv_init(struct xen_drm_front_info *front_info) · line 560
Quoted 10 lines
drivers/gpu/drm/xen/xen_drm_front.c +3
-1drm_mode_config_cleanup (drm_dev);drm_dev_put (drm_dev); -fail: +fail_dev:kfree (drm_info); + front_info->drm_info =NULL ; +fail:return ret; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel