From: Andrea Arcangeli <andrea@suse.de>
To: Ernie Petrides <petrides@redhat.com>
Cc: Marcelo Tosatti <marcelo.tosatti@cyclades.com>,
Dave Kleikamp <shaggy@austin.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][2.4.23-pre7] alternate fix for BUG() in exec_mmap()
Date: Wed, 15 Oct 2003 14:46:11 +0200 [thread overview]
Message-ID: <20031015124610.GB1735@velociraptor.random> (raw)
In-Reply-To: <200310140111.h9E1BR6a015812@pasta.boston.redhat.com>
On Mon, Oct 13, 2003 at 09:11:27PM -0400, Ernie Petrides wrote:
> Yes, this in fact necessary. I have retested with the locking sequence
> shown above and verified that the problem is still fixed.
>
> Further, I've discovered that in my original version, with the mmap_sem
> held across mm_release() and exit_aio(), there are potential deadlocks
> in at least the following hypothetical calling trees:
>
> mm_release()
> put_user()
> direct_put_user()
> __put_user_check()
> __put_user_size()
> __put_user_asm()
> [page fault]
> do_page_fault()
> down_read(&mm->mmap_sem)
>
> exit_aio()
> aio_cancel_all()
> async_poll_cancel()
> aio_put_req()
> put_ioctx()
> __put_ioctx()
> aio_free_ring()
> down_write(&ctx->mm->mmap_sem)
>
> The corrected patch against 2.4.23-pre7, which restores the fast path in
> exec_mmap() and adds the holding of "mmap_sem" across only the exit_mmap()
> call, is attached below. Since "mmap_sem" locking is conceptually higher
> than file system locks in the locking hierarchy, the whole calling tree
> from exit_mmap() on down (including potential fput() calls) should be
> safe to run with "mmap_sem" owned.
>
> Thanks for the help.
>
> Cheers. -ernie
>
>
>
> --- linux-2.4.23-pre7/fs/exec.c.orig
> +++ linux-2.4.23-pre7/fs/exec.c
> @@ -426,6 +426,13 @@ static int exec_mmap(void)
> struct mm_struct * mm, * old_mm;
>
> old_mm = current->mm;
> + if (old_mm && atomic_read(&old_mm->mm_users) == 1) {
> + mm_release();
> + down_write(&old_mm->mmap_sem);
> + exit_mmap(old_mm);
> + up_write(&old_mm->mmap_sem);
> + return 0;
> + }
>
> mm = mm_alloc();
> if (mm) {
looks fine thanks.
Andrea
prev parent reply other threads:[~2003-10-15 12:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-14 1:11 Ernie Petrides
2003-10-15 12:46 ` Andrea Arcangeli [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=20031015124610.GB1735@velociraptor.random \
--to=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com \
--cc=petrides@redhat.com \
--cc=shaggy@austin.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®