delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/15/13:11:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 15 Jul 2004 19:11:52 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: [BUG] mprotect() on Windows NT 5+
Message-ID: <20040715171152.GO1389@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <1089908398 DOT 40f6aeaed7044 AT imp1-q DOT free DOT fr>
Mime-Version: 1.0
In-Reply-To: <1089908398.40f6aeaed7044@imp1-q.free.fr>
User-Agent: Mutt/1.4.2i

On Jul 15 18:19, Xavier Joubert wrote:
> Hello dear Cygwin developpers !
> 
> 
> This is my first post here, so I would like to begin by sending you a big thank 
> for Cygwin ! This is a great tool to port programs to Windows.

Thanks :-)

> I think I found a bug in mprotect() implementation. This call is unable to set 
> some protections (PROT_READ|PROT_WRITE for example) on a given memory area, 
> while it can set some others (PROT_NONE or PROT_READ for example) on the same 
> memory area. From my tests, it seems to happen only on WNT5+ (ie. Windows 2000 
> and Windows XP - detailed results below).

Thanks for the helpful testcase.

The cause is a limitation in newer Windows NT versions, which make sense. 
Well, sort of.  The protection modes PAGE_READWRITE and PAGE_WRITECOPY are
mutually exlusive, which is enforced in calls to VirtualProtect since W2K.

Since your example uses MAP_PRIVATE, which Cygwin maps to PAGE_WRITECOPY,
trying to protect with MAP_WRITE, which internally maps to PAGE_READWRTE,
fails on W2K and later.  I've checked in a fix, so that mprotect tests for
the original protection mode of the first page in the area, and uses
READWRITE or WRITECOPY, whichever matches the original protection.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019