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 16:20:24 +0000 [thread overview]
Message-ID: <20130226162024.GI4503@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1361395671.29360.26.camel@falcor1>
On Wed, Feb 20, 2013 at 04:27:51PM -0500, Mimi Zohar wrote:
> Hi Al,
>
> Are there any negative repercussions to temporarily removing the
> o_direct flag in order to calculate the file hash?
>
> thanks,
>
> Mimi
> -----
>
> Files are measured or appraised based on the IMA policy. When a file
> in policy is opened for read with the O_DIRECT flag set, a deadlock
> occurs due to do_blockdev_direct_IO() taking i_mutex before calling
> filemap_write_and_wait_range(). The i_mutex was previously taken in
> process_measurement(). This patch temporarily removes the O_DIRECT
> flag in order to calculate the hash and restores it once completed.
Why does process_measurement() hold ->i_mutex across that?
It really sounds like "we kinda hope no ->read() will take ->i_mutex,
oops, at least one case does, umm... let's kludge around a bit and
hope no other case shows up".
Locking rules should be documented and they should make sense. You are
introducing a new one and it's really convoluted - "no ->read() instance
for a regular file shall take ->i_mutex unless it's an O_DIRECT open".
next prev parent reply other threads:[~2013-02-26 16:20 UTC|newest]
Thread overview: 12+ 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 13:41 ` Kasatkin, Dmitry
2013-02-26 16:20 ` Al Viro [this message]
2013-02-26 19:32 ` Mimi Zohar
2013-02-26 20:34 ` Al Viro
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=20130226162024.GI4503@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.