In the Linux kernel, the following vulnerability has been resolved:
cdx: Fix possible UAF error in driveroverrideshow()
Fixed a possible UAF problem in driveroverrideshow() in drivers/cdx/cdx.c
This function driveroverrideshow() is part of DEVICEATTRRW, which includes both driveroverrideshow() and driveroverridestore(). These functions can be executed concurrently in sysfs.
The driveroverridestore() function uses driversetoverride() to update the driveroverride value, and driversetoverride() internally locks the device (devicelock(dev)). If driveroverrideshow() reads cdxdev->driveroverride without locking, it could potentially access a freed pointer if driveroverridestore() frees the string concurrently. This could lead to printing a kernel address, which is a security risk since DEVICE_ATTR can be read by all users.
Additionally, a similar pattern is used in drivers/amba/bus.c, as well as many other bus drivers, where device_lock() is taken in the show function, and it has been working without issues.
This potential bug was detected by our experimental static analysis tool, which analyzes locking APIs and paired functions to identify data races and atomicity violations.