All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Xishi Qiu <qiuxishi@huawei.com>
Cc: alan@lxorguk.ukuu.org.uk, Linux MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: a question about protection_map[]
Date: Tue, 12 Jul 2016 04:46:50 +0300	[thread overview]
Message-ID: <20160712014650.GA18041@node> (raw)
In-Reply-To: <57844872.1060806@huawei.com>

On Tue, Jul 12, 2016 at 09:31:30AM +0800, Xishi Qiu wrote:
> On 2016/7/11 21:30, Kirill A. Shutemov wrote:
> 
> > On Mon, Jul 11, 2016 at 06:12:30PM +0800, Xishi Qiu wrote:
> >> Hi,
> >>
> >> We can use mprotect to set read only or read/write.
> >>
> >> mprotect_fixup()
> >> 	vma_set_page_prot()
> >> 		vm_pgprot_modify()
> >> 			vm_get_page_prot()
> >> 				protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]
> >>
> >> The following code shows that prots from __P001(PROT_READ) and __P010(PROT_WRITE)
> >> are the same, so how does it distinguish read only or read/write from mprotect?
> > 
> > It doesn't.
> > 
> > Write protection will be removed by fault handler on next write access to
> > the page. Somewhat suboptiomal, but zero page implemenation relies on this
> > to work properly.
> > 
> 
> Hi Kirill,
> 
> I know, PAGE_READONLY and PAGE_COPY are both missed _PAGE_RW,
> so it will cause page fault, then we will set new prot flag from
> vma, right?

Yes. See wp_page_reuse().

-- 
 Kirill A. Shutemov

--
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>

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Xishi Qiu <qiuxishi@huawei.com>
Cc: alan@lxorguk.ukuu.org.uk, Linux MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: a question about protection_map[]
Date: Tue, 12 Jul 2016 04:46:50 +0300	[thread overview]
Message-ID: <20160712014650.GA18041@node> (raw)
In-Reply-To: <57844872.1060806@huawei.com>

On Tue, Jul 12, 2016 at 09:31:30AM +0800, Xishi Qiu wrote:
> On 2016/7/11 21:30, Kirill A. Shutemov wrote:
> 
> > On Mon, Jul 11, 2016 at 06:12:30PM +0800, Xishi Qiu wrote:
> >> Hi,
> >>
> >> We can use mprotect to set read only or read/write.
> >>
> >> mprotect_fixup()
> >> 	vma_set_page_prot()
> >> 		vm_pgprot_modify()
> >> 			vm_get_page_prot()
> >> 				protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]
> >>
> >> The following code shows that prots from __P001(PROT_READ) and __P010(PROT_WRITE)
> >> are the same, so how does it distinguish read only or read/write from mprotect?
> > 
> > It doesn't.
> > 
> > Write protection will be removed by fault handler on next write access to
> > the page. Somewhat suboptiomal, but zero page implemenation relies on this
> > to work properly.
> > 
> 
> Hi Kirill,
> 
> I know, PAGE_READONLY and PAGE_COPY are both missed _PAGE_RW,
> so it will cause page fault, then we will set new prot flag from
> vma, right?

Yes. See wp_page_reuse().

-- 
 Kirill A. Shutemov

  reply	other threads:[~2016-07-12  1:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 10:12 a question about protection_map[] Xishi Qiu
2016-07-11 10:12 ` Xishi Qiu
2016-07-11 13:30 ` Kirill A. Shutemov
2016-07-11 13:30   ` Kirill A. Shutemov
2016-07-12  1:31   ` Xishi Qiu
2016-07-12  1:31     ` Xishi Qiu
2016-07-12  1:46     ` Kirill A. Shutemov [this message]
2016-07-12  1:46       ` Kirill A. Shutemov

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=20160712014650.GA18041@node \
    --to=kirill@shutemov.name \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=qiuxishi@huawei.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 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.