linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: vinayak menon <vinayakm.list@gmail.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm: fix zero page check in vm_normal_page
Date: Tue, 27 May 2014 16:37:24 +0400	[thread overview]
Message-ID: <CALYGNiMnUCWtZSPxjOSn-4h2rgya4e+TJFcUMAcMWT+dy8dt9w@mail.gmail.com> (raw)
In-Reply-To: <CAOaiJ-m8LjrnV868b7Z7-DDkGcubwQzCFOBYNDY7r=v5GuWkbw@mail.gmail.com>

On Tue, May 27, 2014 at 4:10 PM, vinayak menon <vinayakm.list@gmail.com> wrote:
> On Tue, May 27, 2014 at 5:18 PM, Konstantin Khlebnikov <koct9i@gmail.com> wrote:
>> On Tue, May 27, 2014 at 3:43 PM, vinayak menon <vinayakm.list@gmail.com> wrote:
>>> On Tue, May 27, 2014 at 5:01 PM, Konstantin Khlebnikov <koct9i@gmail.com> wrote:
>>>> On Tue, May 27, 2014 at 2:31 PM, Kirill A. Shutemov
>>>> <kirill.shutemov@linux.intel.com> wrote:
>>>>> Vinayak Menon wrote:
>>>>>> An issue was observed when a userspace task exits.
>>>>>> The page which hits error here is the zero page.
>>>>>> In zap_pte_range, vm_normal_page gets called, and it
>>>>>> returns a page address and not NULL, even though the
>>>>>> pte corresponds to zero pfn. In this case,
>>>>>> HAVE_PTE_SPECIAL is not set, and VM_MIXEDMAP is set
>>>>>> in vm_flags. In the case of VM_MIXEDMAP , only pfn_valid
>>>>>> is checked, and not is_zero_pfn. This results in
>>>>>> zero page being returned instead of NULL.
>>>>>>
>>>>>> BUG: Bad page map in process mediaserver  pte:9dff379f pmd:9bfbd831
>>>>>> page:c0ed8e60 count:1 mapcount:-1 mapping:  (null) index:0x0
>>>>>> page flags: 0x404(referenced|reserved)
>>>>>> addr:40c3f000 vm_flags:10220051 anon_vma:  (null) mapping:d9fe0764 index:fd
>>>>>> vma->vm_ops->fault:   (null)
>>>>>> vma->vm_file->f_op->mmap: binder_mmap+0x0/0x274
>>>>>
>>>>> How do we get zero_pfn there. We shouldn't use zero page for file mappings.
>>>>> binder does some tricks?
>>>>
>>>> Its vm_ops doesn't provide ->fault method at all.
>>>> Seems like all ptes must be populated at the mmap time.
>>>> For some reason read page fault had happened and handle_pte_fault()
>>>> handled it in do_anonymous_page() which maps zero_page.
>>>>
>>> When the task crashed, it was ptraced by debuggered and the areas were
>>> dumped. And this resulted in the read page fault.
>>
>> Anyway, this bug in the binder. It must either populate all PTEs in ->mmap()
>> or provide ->fault() method. Falling into do_anonymous_page() isn't funny.
>
> Ok. But in vm_normal_page shouldn't we check for zero_pfn in the case
> of VM_MIXEDMAP ?

I don't think so. VM_MIXEDMAP shouldn't have zero_pfn.
It isn't expected to be here, for example in your case next fault for
write will remap
that zero page for write becaue do_wp_page() doesn't expect to see it here.

In case of HAVE_PTE_SPECIAL it's checked because zero_page _also_
installed as special pte and
this must be the only one possible special-pte in non-mixedmap/pfnmap vmas.

--
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:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2014-05-27 12:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-27  4:56 Vinayak Menon
2014-05-27 10:31 ` Kirill A. Shutemov
2014-05-27 11:31   ` Konstantin Khlebnikov
2014-05-27 11:43     ` vinayak menon
2014-05-27 11:48       ` Konstantin Khlebnikov
2014-05-27 12:10         ` vinayak menon
2014-05-27 12:37           ` Konstantin Khlebnikov [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=CALYGNiMnUCWtZSPxjOSn-4h2rgya4e+TJFcUMAcMWT+dy8dt9w@mail.gmail.com \
    --to=koct9i@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=vinayakm.list@gmail.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