title: uio: Fix use-after-free in uio_open
description: In the Linux kernel, the following vulnerability has been resolved:
uio: Fix use-after-free in uio_open
core-1				core-2
-------------------------------------------------------
uio_unregister_device		uio_open
idev = idr_find()
device_unregister(&idev->dev)
put_device(&idev->dev)
uio_device_release
get_device(&idev->dev)
kfree(idev)
uio_free_minor(minor)
uio_release
put_device(&idev->dev)
kfree(idev)
-------------------------------------------------------
In the core-1 uio_unregister_device(), the device_unregister will kfree
idev when the idev->dev kobject ref is 1. But after core-1
device_unregister, put_device and before doing kfree, the core-2 may
get_device. Then:
1. After core-1 kfree idev, the core-2 will do use-after-free for idev.
2. When core-2 do uio_release and put_device, the idev will be double
freed.
To address this issue, we can get idev atomic & inc idev reference with
minor_lock.
affected:
{
product: Linux
vendor: Linux
defaultStatus: unaffected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 57c5f4df0a5a, lessThan: 3174e0f7de1b, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: e93da893d52d, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 5e0be1229ae1, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 5cf604ee538e, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 17a8519cb359, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 35f102607054, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 913205930da6, status: affected, versionType: git
version: 57c5f4df0a5a, lessThan: 0c9ae0b86050, status: affected, versionType: git
}
{
product: Linux
vendor: Linux
defaultStatus: affected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 4.18, status: affected
version: 0, lessThan: 4.18, status: unaffected, versionType: custom
version: 4.19.306, lessThanOrEqual: 4.19.*, status: unaffected, versionType: custom
version: 5.4.268, lessThanOrEqual: 5.4.*, status: unaffected, versionType: custom
version: 5.10.209, lessThanOrEqual: 5.10.*, status: unaffected, versionType: custom
version: 5.15.148, lessThanOrEqual: 5.15.*, status: unaffected, versionType: custom
version: 6.1.74, lessThanOrEqual: 6.1.*, status: unaffected, versionType: custom
version: 6.6.13, lessThanOrEqual: 6.6.*, status: unaffected, versionType: custom
version: 6.7.1, lessThanOrEqual: 6.7.*, status: unaffected, versionType: custom
version: 6.8, lessThanOrEqual: *, status: unaffected, versionType: original_commit_for_fix
}
