CVE-2022-50417: drm/panfrost: Fix GEM handle creation ref-counting
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
drm/panfrost: Fix GEM handle creation ref-counting
panfrost_gem_create_with_handle() previously returned a BO but with the only reference being from the handle, which user space could in theory guess and release, causing a use-after-free. Additionally if the call to panfrost_gem_mapping_get() in panfrost_ioctl_create_bo() failed then a(nother) reference on the BO was dropped.
The _create_with_handle() is a problematic pattern, so ditch it and instead create the handle in panfrost_ioctl_create_bo(). If the call to panfrost_gem_mapping_get() fails then this means that user space has indeed gone behind our back and freed the handle. In which case just return an error code.
The Linux kernel CVE team has assigned CVE-2022-50417 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.2 with commit f3ba91228e8e917e5bd6c4b72bfe846933d17370 and fixed in 5.10.163 with commit 0b70f6ea4d4f2b4d4b291d86ab76b4d07394932c Issue introduced in 5.2 with commit f3ba91228e8e917e5bd6c4b72bfe846933d17370 and fixed in 5.15.87 with commit 4f1105ee72d8c7c35d90e3491b31b2d9d6b7e33a Issue introduced in 5.2 with commit f3ba91228e8e917e5bd6c4b72bfe846933d17370 and fixed in 6.0.19 with commit 3f9feffa8a5ab08b4e298a27b1aa7204a7d42ca2 Issue introduced in 5.2 with commit f3ba91228e8e917e5bd6c4b72bfe846933d17370 and fixed in 6.1.5 with commit ba3d2c2380e7129b525a787489c0b7e819a3b898 Issue introduced in 5.2 with commit f3ba91228e8e917e5bd6c4b72bfe846933d17370 and fixed in 6.2 with commit 4217c6ac817451d5116687f3cc6286220dc43d49
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-50417
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/panfrost/panfrost_drv.c
drivers/gpu/drm/panfrost/panfrost_gem.c
drivers/gpu/drm/panfrost/panfrost_gem.h
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/0b70f6ea4d4f2b4d4b291d86ab76b4d07394932c https://git.kernel.org/stable/c/4f1105ee72d8c7c35d90e3491b31b2d9d6b7e33a https://git.kernel.org/stable/c/3f9feffa8a5ab08b4e298a27b1aa7204a7d42ca2 https://git.kernel.org/stable/c/ba3d2c2380e7129b525a787489c0b7e819a3b898 https://git.kernel.org/stable/c/4217c6ac817451d5116687f3cc6286220dc43d49