On Mon, Nov 23, 2026 at 04:10:00PM -0500, Mimi Zohar wrote: > The only option I came up with is to try sb_start_write_trylock() in > ima_update_xattr(), after the hashing and just before the xattr write, and if > it > fails, defer only that write to a workqueue.
A workqueue doesn't work. It would cause spurious EBUSY and break uapi guarantees. The worker has to pin the filesystem until after the thaw. If it pins the mount then umount() after the last close() fails with EBUSY until the worker has run. A simple fsfreeze -u /mnt umount /mnt would do it. If it pins the superblock instead then umount() succeeds but the device stays busy and mkfs or mounting it again fails with EBUSY. It's the same reason the final fput() is done from task_work and not from a workqueue. Userspace expects devices and filesystem remounts to work after umount() and last close(). > After thaw, an open could flush the > pending update inline before verifying, so only the window during the freeze > is > affected. > > Options for that window: > > 1. Accept -EACCES for files closed during a freeze until thaw. (1) is fine. And then we don't need the workqueue at all afaict. close() uses sb_start_write_trylock() and if the filesystem is frozen it leaves the update pending in the iint. The next open after the thaw flushes it inline before verifying. If the inode is evicted or the filesystem is unmounted before the next open you are back at a stale hash. > 2. Make the open wait for thaw. That changes behavior for read opens, and > the wait would have to happen before taking iint->mutex. No, the read side never waits for a thaw. Even touch_atime() only uses a trylock. We could block in close() but only when an update may be needed. So that could mean, takes sb_start_write() before iint->mutex if the file was opened for writing and IMA_UPDATE_XATTR is set. Iirc, close() already blocks on a frozen filesystem today. The last close of an unlinked file on ext4 ends up in ext4_evict_inode() which waits in sb_start_intwrite(). So it's not unheard of. Still disgusting though.
