Re: [PATCH 05/10] dm-ima: Fix UAF errors and measuring incorrect context
Mikulas Patocka <[email protected]>
| Newsgroups | org.kernel.vger.linux-integrity,dev.linux.lists.dm-devel |
|---|---|
| Message-ID | <[email protected]> |
Hi On Mon, 13 Apr 2026, Benjamin Marzinski wrote: > + smp_mb__before_atomic(); > + atomic_inc(&ima->measure_idx); > + wake_up_all(&ima->ima_wq); There should be smp_mb__after_atomic() after atomic_inc() and before wake_up_all(). Otherwise, the increment of atomic_inc could be moved inside the wait queue spinlock in wake_up_all and executed after the wait queue is checked for being empty. Generally, the atomic variables and barriers are very hard to get right, this is not performance-critical code that would justify the complications, so I suggest to use a normal spinlock instead. You can use something like: spin_lock_irq(&ima->ima_wq.lock); ima->measure_idx++; wake_up_all_locked(&ima->ima_wq); spin_unlock_irq(&ima->ima_wq.lock); --- this would be obviously safe and easy to verify. Mikulas