mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Mimi Zohar <zohar@linux.ibm.com>,
	 Roberto Sassu <roberto.sassu@huawei.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	 Eric Snowberg <eric.snowberg@oracle.com>
Cc: Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	 "Serge E. Hallyn" <serge@hallyn.com>, Jan Kara <jack@suse.cz>,
	linux-integrity@vger.kernel.org,
	 linux-security-module@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: ima/evm: security.ima and security.evm get written to frozen filesystems
Date: Tue, 24 Nov 2026 17:53:35 +0100	[thread overview]
Message-ID: <20261124-eisstadion-burgen-kommt-c27ea3d3bf74@brauner> (raw)
In-Reply-To: <7cbff903ec83459cb9779246feae1fb7f09f1ff9.camel@linux.ibm.com>

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.

      reply	other threads:[~2026-11-24 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 23:55 Christian Brauner
2026-11-23 21:10 ` Mimi Zohar
2026-11-24 16:53   ` Christian Brauner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124-eisstadion-burgen-kommt-c27ea3d3bf74@brauner \
    --to=brauner@kernel.org \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=roberto.sassu@huawei.com \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®