In the Linux kernel, the following vulnerability has been resolved: functionfs: fix the open/removal races ffsepfileopen() can race with removal, ending up with file->privatedata pointing to freed object. There is a total count of opened files on functionfs (both ep0 and dynamic ones) and when it hits zero, dynamic files get removed. Unfortunately, that removal can happen while another thread is in ffsepfileopen(), but has not incremented the count yet. In that case open will succeed, leaving us with UAF on any subsequent read() or write(). The root cause is that ffs->opened is misused; atomicdecandtest() vs. atomicaddreturn() is not a good idea, when object remains visible all along. To untangle that * serialize openers on ffs->mutex (both for ep0 and for dynamic files) * have dynamic ones use atomicincnotzero() and fail if we had zero ->opened; in that case the file we are opening is doomed. * have the inodes of dynamic files marked on removal (from the callback of simplerecursiveremoval()) - clear ->iprivate there. * have open of dynamic ones verify they hadn't been already removed, along with checking that state is FFS_ACTIVE.