Linux kernel use-after-free in PPS generator ioctls
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
6.18.637.3.27.4-rc1In the Linux kernel, the following vulnerability has been resolved:
pps: generators: don't use the driver's info after unregister
A file that was opened before pps_gen_unregister_source() keeps pps_gen, and with it the pointer to the driver's pps_gen_source_info. PPS_GEN_SETENABLE and PPS_GEN_USESYSTEMCLOCK keep using that pointer after the driver has gone:
- pps_gen_tio allocates its info with devm_kzalloc(), so after an unbind both ioctls read freed memory, and SETENABLE calls the driver's enable() with its freed private data.
- pps_gen-dummy does not set info->owner, so it can be unloaded while the file is open, and the ioctls then read the unloaded module's data and call its code.
TIO can't probe in a VM, as it needs ART. A test driver that registers its info in devm memory like TIO does, unbound while /dev/pps-gen0 is open, gives:
BUG: KASAN: slab-use-after-free in pps_gen_cdev_ioctl+0x4c1/0x580 Read of size 1 at addr ffff88800e647f38 by task ppsgen64/145 ... Freed by task 146: kfree+0x25a/0x6d0 release_nodes+0xd1/0x140 devres_release_all+0x10e/0x1a0 device_unbind_cleanup+0x71/0x250 device_release_driver_internal+0x41b/0x570 unbind_store+0xd9/0x100
and unloading pps_gen-dummy while its file is open oopses:
From the CVE record · Linux
The Linux kernel’s PPS generator ioctl handler can use driver information after a PPS generator is unregistered. A local user with an already-open PPS generator device file can trigger a use-after-free or access to unloaded module data through PPS_GEN_SETENABLE or PPS_GEN_USESYSTEMCLOCK after the driver is unbound or unloaded.
Engineers running Linux kernels with PPS generator drivers should check whether their kernel includes the fix; affected versions are not specified.