All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Arve Hj?nnev?g <arve@android.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org, airlied@linux.ie,
	carsteno@de.ibm.com, steiner@sgi.com
Subject: Re: [patches] VM-related fixes
Date: Tue, 6 Mar 2012 05:57:06 +0000	[thread overview]
Message-ID: <20120306055706.GQ23916@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAMP5XgdmjL68qZJ8D0pNz-S5m-BauTzPyQ9Xv1SPgdZVMiZMpg@mail.gmail.com>

On Mon, Mar 05, 2012 at 09:25:05PM -0800, Arve Hj?nnev?g wrote:
> > Sorry, no.
> > ? ? ? ? ? ? ? ?down_write(&mm->mmap_sem);
> > ? ? ? ? ? ? ? ?vma = proc->vma;
> > ? ? ? ? ? ? ? ?if (vma && mm != vma->vm_mm) {
> > does *not* do what you seem to describe; there's nothing to protect you
> > from proc->vma getting freed under you right between load from proc->vma
> > and check of vma->mm. ?->mmap_sem on the right mm would prevent that,
> > but this one doesn't guarantee anything. ?Get preempted after the second
> > line quoted above and by the time you get the timeslice back, you might
> > have had munmap() done by another thread, with vma freed, its memory
> > recycled, etc.
> >
> 
> OK, if the memory got freed and then re-used by someone who stored a
> value that matched a pointer to the mm struct that was just locked,
> this check will fail to catch it. I can check against a cached vm_mm
> member from mmap instead, assuming this will not change before
> ->close() is called. Does that sound reasonable, or is there a better
> way to check this?

Huh?  Sorry, I hadn't been able to parse that - what do you want to cache,
where and what do you want to check?  Again, at that point *(proc->vma)
may very well be random garbage, so looking at it would be pointless;
the value you had at ->mmap() time would be simply current->mm of mmap(2)
caller; if you want to check that it matches that of opener, fine,
but then why not do just that in ->mmap()?

  reply	other threads:[~2012-03-06  5:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05  6:37 [patches] VM-related fixes Al Viro
2012-03-05  6:38 ` [PATCH 1/3] aout: move setup_arg_pages() prior to reading/mapping the binary Al Viro
2012-03-05  6:39 ` [PATCH 2/3] VM_GROWS{UP,DOWN} shouldn't be set on shmem VMAs Al Viro
2012-03-05  6:40 ` [PATCH 3/3] flush_tlb_range() needs ->page_table_lock when ->mmap_sem is not held Al Viro
2012-03-05 20:30   ` Linus Torvalds
2012-03-05 20:53     ` Al Viro
2012-03-09 21:06       ` Benjamin Herrenschmidt
2012-03-06  3:38 ` [patches] VM-related fixes Arve Hjønnevåg
2012-03-06  4:10   ` Al Viro
2012-03-06  5:25     ` Arve Hjønnevåg
2012-03-06  5:57       ` Al Viro [this message]
2012-03-06  6:36         ` Arve Hjønnevåg
2012-03-08 23:43     ` [PATCH] Staging: android: binder: Fix use-after-free bug Arve Hjønnevåg

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=20120306055706.GQ23916@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=airlied@linux.ie \
    --cc=arve@android.com \
    --cc=carsteno@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steiner@sgi.com \
    --cc=torvalds@linux-foundation.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 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.