From: Dave Chinner <david@fromorbit.com>
To: Jan Kara <jack@suse.cz>
Cc: dchinner@redhat.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: Mapping range locking and related stuff
Date: Sat, 28 Sep 2013 09:32:02 +1000 [thread overview]
Message-ID: <20130927233202.GY26872@dastard> (raw)
In-Reply-To: <20130927204214.GA6445@quack.suse.cz>
On Fri, Sep 27, 2013 at 10:42:14PM +0200, Jan Kara wrote:
> Hello,
>
> so recently I've spent some time rummaging in get_user_pages(), fault
> code etc. The use of mmap_sem is really messy in some places (like V4L
> drivers, infiniband,...). It is held over a deep & wide call chains and
> it's not clear what's protected by it, just in the middle of that is a call
> to get_user_pages(). Anyway that's mostly a side note.
>
> The main issue I found is with the range locking itself. Consider someone
> doing:
> fd = open("foo", O_RDWR);
> base = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> write(fd, base, 4096);
>
> The write() is an interesting way to do nothing but if the mapping range
> lock will be acquired early (like in generic_file_aio_write()), then this
> would deadlock because generic_perform_write() will try to fault in
> destination buffer and that will try to get the range lock for the same
> range again.
Quite frankly, I'd like to see EFAULT or EDEADLOCK returned to the
caller doing something like this. It's a stupid thing to do, and
while I beleive in giving people enough rope to hang themselves,
the contortions we are going through here to provide that rope
doesn't seem worthwhile at all.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2013-09-27 23:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-27 20:42 Mapping range locking and related stuff Jan Kara
2013-09-27 23:32 ` Dave Chinner [this message]
2013-09-30 16:25 ` Jan Kara
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=20130927233202.GY26872@dastard \
--to=david@fromorbit.com \
--cc=dchinner@redhat.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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;
as well as URLs for NNTP newsgroup(s).