Samsung Graphics 2D Driver Use-After-Free Vulnerability
The Samsung Graphics 2D driver (/dev/fimg2d) is accessible by unprivileged users/applications. It was found that the ioctl implementation for this driver contains a locking error which can lead to memory errors (such as use-after-free) due to a race condition. The key observation is in the locking routine definitions in fimg2d.h, where the g2d_lock/g2d_unlock routines are no-ops when BLIT_WORKQUE is defined, which appears to be the default configuration. Unfortunately the alternative spin lock routines are not used consistently with this configuration. For example, the FIMG2D_BITBLT_BLIT ioctl command can lead to a use-after-free vulnerability if two processes with different mm’s have access to the same file descriptor.