gpu/xen: Fix a use after free in xen_drm_drv_init
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Tue, 23 Mar 2021 01:46:56 +0000 (18:46 -0700)
committerOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Fri, 26 Mar 2021 05:40:03 +0000 (07:40 +0200)
commit52762efa2b256ed1c5274e5177cbd52ee11a2f6a
tree3487d388c1c06ab4ccc8c61ee04b727520c9f335
parent50891bead80bc79871528c2962d65c781c02330b
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.

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210323014656.10068-1-lyl2019@mail.ustc.edu.cn
drivers/gpu/drm/xen/xen_drm_front.c