From: Al Viro <viro@ZenIV.linux.org.uk>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: linux-security-module <linux-security-module@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ima: prevent dead lock when a file is opened for direct io
Date: Tue, 26 Feb 2013 20:34:08 +0000 [thread overview]
Message-ID: <20130226203408.GJ4503@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1361907128.2908.180.camel@falcor1.watson.ibm.com>
On Tue, Feb 26, 2013 at 02:32:08PM -0500, Mimi Zohar wrote:
> Before anything gets access to the file, the file needs to be measured,
> appraised, and/or audited, based on policy. If IMA-appraisal is enabled
> and the file is in policy, we enforce local file integrity and return
> -EINVAL on failure, similar to LSMs.
>
> Appraising the file is a two step process. Before appraising the file
> data's integrity, we verify the integrity of the file metadata. Included
> in the 'security.evm' calculation is the ino, generation, uid, gid,
> mode, uuid, and the security xattrs. 'security.ima' contains the file
> data hash or a signature based on the hash.
>
> The i_mutex is held when making file metadata changes (eg. xattrs,
> chmod, ...). We hold the i_mutex through the entire verification,
> preventing the file data/metadata from changing.
->i_mutex is *not* guaranteed to prevent file data changes. It does
cover metadata, but that's it. ->write() is not required to take it.
Note, BTW, that as soon as you've dropped ->i_mutex, the metadata can
be changed by somebody else.
What do you achieve by holding it over the vfs_read() call?
> I guess I wasn't clear here. IMA always takes the i_mutex, regardless
> of the O_DIRECT flag. When a file is opened for read,
> process_measurement() takes the i_mutex and then, if the file was opened
> with the O_DIRECT flag, do_blockdev_direct_IO() attempts to take the
> i_mutex again, causing the lockdep.
*sigh*
Do you actually disagree with my description of the locking rules you
implicitly rely upon? Suppose wankfs_file_read() happens to grab
->i_mutex for some reason; without IMA it used to be perfectly legitimate.
With IMA it will deadlock as soon as IMA decides that such file is worth
its attention. So these days the rule has (silently) become
* ->read() on a regular file is not allowed to touch ->i_mutex
and with your proposed change it becomes (still undocumented)
* ->read() on a regular file is not allowed to touch ->i_mutex unless
O_DIRECT is present in file flags at the moment of ->read()
Correct?
next prev parent reply other threads:[~2013-02-26 20:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-20 21:27 [PATCH] ima: prevent dead lock when a file is opened for direct io Mimi Zohar
2013-02-26 13:41 ` Kasatkin, Dmitry
2013-02-26 16:20 ` Al Viro
2013-02-26 19:32 ` Mimi Zohar
2013-02-26 20:34 ` Al Viro [this message]
2013-02-26 23:22 ` Mimi Zohar
2013-02-27 9:21 ` Kasatkin, Dmitry
2013-02-27 12:26 ` Kasatkin, Dmitry
2013-02-27 13:57 ` Mimi Zohar
2013-02-27 19:00 ` Al Viro
2013-02-27 19:45 ` Mimi Zohar
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=20130226203408.GJ4503@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=zohar@linux.vnet.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