Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440622

Re: a question about protection_map[]

From "Kirill A. Shutemov" <kirill@shutemov.name>
Newsgroups linux.kernel
Subject Re: a question about protection_map[]
Date 2016-07-11 15:40 +0200
Message-ID <rTJBf-7EI-9@gated-at.bofh.it> (permalink)
References <rTGtH-5FU-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

-- 
 Kirill A. Shutemov

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

a question about protection_map[] Xishi Qiu <qiuxishi@huawei.com> - 2016-07-11 12:20 +0200
  Re: a question about protection_map[] "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-07-11 15:40 +0200
    Re: a question about protection_map[] Xishi Qiu <qiuxishi@huawei.com> - 2016-07-12 03:40 +0200
      Re: a question about protection_map[] "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-07-12 03:50 +0200

csiph-web