From: Andrea Arcangeli <andrea@suse.de>
To: Andrew Morton <akpm@digeo.com>
Cc: dmccr@us.ibm.com, mika.penttila@kolumbus.fi, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: Race between vmtruncate and mapped areas?
Date: Thu, 15 May 2003 10:55:19 +0200 [thread overview]
Message-ID: <20030515085519.GV1429@dualathlon.random> (raw)
In-Reply-To: <20030515013245.58bcaf8f.akpm@digeo.com>
On Thu, May 15, 2003 at 01:32:45AM -0700, Andrew Morton wrote:
> Andrea Arcangeli <andrea@suse.de> wrote:
> >
> > what do you think of this untested fix?
> >
> > I wonder if vm_file is valid for all nopage operations, I think it
> > should, and the i_mapping as well should always exist, but in the worst
> > case it shouldn't be too difficult to take care of special cases
> > (just checking if the new_page is reserved and if the vma is VM_SPECIAL)
> > would eliminate most issues, shall there be any.
>
> yes, I think this is a good solution.
>
> In 2.5 (at least) we can push all the sequence number work into
> filemap_nopage(), and add a new vm_ops->revalidate() thing, so do_no_page()
> doesn't need to know about inodes and such.
>
> So the mm/memory.c part would look something like:
this is your i_size check idea, and it's still racy (though less racy
than before ;), you will corrupt the user address space again if you get
two truncates under you (the first truncating the page under fault, and
the second extending the file past the page under fault) and since you
only call revalidate after re-taking the spinlock you can't catch the
first truncate that mandates the page to be zeroed out despite the
i_size check.
you could trap this by checking the page->mapping inside the
page_table_lock probably but taking lock_page before page_table_lock in
do_no_page is way overkill compared to my read-lockless patch.
>
> diff -puN mm/memory.c~a mm/memory.c
> --- 25/mm/memory.c~a 2003-05-15 01:29:21.000000000 -0700
> +++ 25-akpm/mm/memory.c 2003-05-15 01:32:02.000000000 -0700
> @@ -1399,7 +1399,7 @@ do_no_page(struct mm_struct *mm, struct
> pmd, write_access, address);
> pte_unmap(page_table);
> spin_unlock(&mm->page_table_lock);
> -
> +retry:
> new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, 0);
>
> /* no page was available -- either SIGBUS or OOM */
> @@ -1408,9 +1408,11 @@ do_no_page(struct mm_struct *mm, struct
> if (new_page == NOPAGE_OOM)
> return VM_FAULT_OOM;
>
> - pte_chain = pte_chain_alloc(GFP_KERNEL);
> - if (!pte_chain)
> - goto oom;
> + if (!pte_chain) {
> + pte_chain = pte_chain_alloc(GFP_KERNEL);
> + if (!pte_chain)
> + goto oom;
> + }
>
> /*
> * Should we do an early C-O-W break?
> @@ -1428,6 +1430,17 @@ do_no_page(struct mm_struct *mm, struct
> }
>
> spin_lock(&mm->page_table_lock);
> +
> + /*
> + * comment goes here
> + */
> + if (vma->vm_ops && vma->vm_ops->revalidate &&
> + vma->vm_ops->revalidate(vma, address) {
> + spin_unlock(&mm->page_table_lock);
> + put_page(new_page);
> + goto retry;
> + }
> +
> page_table = pte_offset_map(pmd, address);
>
> /*
>
> _
>
Andrea
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2003-05-15 8:55 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-13 20:44 Dave McCracken
2003-05-13 20:58 ` Mika Penttilä
2003-05-13 21:04 ` William Lee Irwin III
2003-05-13 22:26 ` Dave McCracken
2003-05-13 22:49 ` William Lee Irwin III
2003-05-13 23:00 ` Dave McCracken
2003-05-13 23:11 ` William Lee Irwin III
2003-05-13 23:16 ` Dave McCracken
2003-05-13 23:20 ` William Lee Irwin III
2003-05-13 23:28 ` Dave McCracken
2003-05-13 23:29 ` William Lee Irwin III
2003-05-13 23:16 ` William Lee Irwin III
2003-05-14 1:10 ` Andrew Morton
2003-05-14 15:02 ` Dave McCracken
2003-05-14 1:10 ` Andrew Morton
2003-05-14 15:02 ` Dave McCracken
2003-05-14 15:06 ` William Lee Irwin III
2003-05-14 15:25 ` Dave McCracken
2003-05-14 16:42 ` Gerrit Huizenga
2003-05-14 17:34 ` Andrew Morton
2003-05-14 17:42 ` Dave McCracken
2003-05-14 17:57 ` Andrew Morton
2003-05-14 18:05 ` Dave McCracken
2003-05-14 18:17 ` Andrew Morton
2003-05-14 18:24 ` Dave McCracken
2003-05-14 18:53 ` Andrew Morton
2003-05-15 8:50 ` Andrea Arcangeli
2003-05-14 19:02 ` Rik van Riel
2003-05-14 19:04 ` Rik van Riel
2003-05-14 19:07 ` Dave McCracken
2003-05-14 19:11 ` Rik van Riel
2003-05-15 0:49 ` Andrea Arcangeli
2003-05-15 2:36 ` Rik van Riel
2003-05-15 9:46 ` Andrea Arcangeli
2003-05-15 9:55 ` Andrew Morton
2003-05-15 8:32 ` Andrew Morton
2003-05-15 8:42 ` Andrew Morton
2003-05-15 8:55 ` Andrea Arcangeli [this message]
2003-05-15 9:20 ` Andrew Morton
2003-05-15 9:40 ` Andrea Arcangeli
2003-05-15 9:58 ` Andrew Morton
2003-05-15 16:38 ` Daniel McNeil
2003-05-15 19:19 ` Andrea Arcangeli
2003-05-15 22:04 ` Daniel McNeil
2003-05-15 23:17 ` Andrea Arcangeli
2003-05-17 0:27 ` Daniel McNeil
2003-05-17 17:29 ` Andrea Arcangeli
2003-05-13 21:00 ` William Lee Irwin III
2003-05-17 18:19 Paul McKenney
2003-05-17 18:42 ` Andrea Arcangeli
2003-05-19 18:11 Paul McKenney
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=20030515085519.GV1429@dualathlon.random \
--to=andrea@suse.de \
--cc=akpm@digeo.com \
--cc=dmccr@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mika.penttila@kolumbus.fi \
/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