From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758872AbcGKNaV (ORCPT ); Mon, 11 Jul 2016 09:30:21 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:36337 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbcGKNaT (ORCPT ); Mon, 11 Jul 2016 09:30:19 -0400 Date: Mon, 11 Jul 2016 16:30:15 +0300 From: "Kirill A. Shutemov" To: Xishi Qiu Cc: alan@lxorguk.ukuu.org.uk, Linux MM , LKML Subject: Re: a question about protection_map[] Message-ID: <20160711133015.GA8028@node.shutemov.name> References: <5783710E.3070602@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5783710E.3070602@huawei.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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