CVE-2022-48771: drm/vmwgfx: Fix stale file descriptors on failed usercopy
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
drm/vmwgfx: Fix stale file descriptors on failed usercopy
A failing usercopy of the fence_rep object will lead to a stale entry in the file descriptor table as put_unused_fd() won't release it. This enables userland to refer to a dangling 'file' object through that still valid file descriptor, leading to all kinds of use-after-free exploitation scenarios.
Fix this by deferring the call to fd_install() until after the usercopy has succeeded.
The Linux kernel CVE team has assigned CVE-2022-48771 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.14 with commit c906965dee22 and fixed in 4.14.264 with commit e8d092a62449 Issue introduced in 4.14 with commit c906965dee22 and fixed in 4.19.227 with commit 0008a0c78fc3 Issue introduced in 4.14 with commit c906965dee22 and fixed in 5.4.175 with commit 84b1259fe36a Issue introduced in 4.14 with commit c906965dee22 and fixed in 5.10.95 with commit ae2b20f27732 Issue introduced in 4.14 with commit c906965dee22 and fixed in 5.15.18 with commit 6066977961fc Issue introduced in 4.14 with commit c906965dee22 and fixed in 5.16.4 with commit 1d833b27fb70 Issue introduced in 4.14 with commit c906965dee22 and fixed in 5.17 with commit a0f90c881570
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2022-48771
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/e8d092a62449dcfc73517ca43963d2b8f44d0516 https://git.kernel.org/stable/c/0008a0c78fc33a84e2212a7c04e6b21a36ca6f4d https://git.kernel.org/stable/c/84b1259fe36ae0915f3d6ddcea6377779de48b82 https://git.kernel.org/stable/c/ae2b20f27732fe92055d9e7b350abc5cdf3e2414 https://git.kernel.org/stable/c/6066977961fc6f437bc064f628cf9b0e4571c56c https://git.kernel.org/stable/c/1d833b27fb708d6fdf5de9f6b3a8be4bd4321565 https://git.kernel.org/stable/c/a0f90c8815706981c483a652a6aefca51a5e191c