The current semaphore code allows a potential use after free: in exit_sem we mayAcked-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
free the task's sem_undo_list while there is still another task looping through
the same semaphore set and cleaning the sem_undo list at freeary function (the
task called IPC_RMID for the same semaphore set).
For example, with a test program [1] running which keeps forking a lot of processes
(which then do a semop call with SEM_UNDO flag), and with the parent right after
removing the semaphore set with IPC_RMID, and a kernel built with CONFIG_SLAB,
CONFIG_SLAB_DEBUG and CONFIG_DEBUG_SPINLOCK, you can easily see something like
the following in the kernel log:
Signed-off-by: Herton R. Krzesinski <herton@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx