delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/02/03/03:57:39

X-Spam-Check-By: sourceware.org
Date: Fri, 3 Feb 2006 09:57:27 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Possible bug with mmap on XP?
Message-ID: <20060203085727.GY15572@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <200602030016 DOT k130GYOk002533 AT base686 DOT home DOT org>
Mime-Version: 1.0
In-Reply-To: <200602030016.k130GYOk002533@base686.home.org>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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

On Feb  2 18:16, Dave Bodenstab wrote:
> I searched the mailing list archives and googled, but failed to find
> anything specific to XP regarding this...
> 
> I am using the latest version (1.5.19-4) of Cygwin.
> 
> I had previously ported a unix prog that used mmap to Cygwin.  On win2k
> it works fine.  When I copied the prog to a newly-installed win XP
> professional system, I get:
> 
>   mmap failed (Permission denied)
> 
> when attempting to do a 
> 
>   mmap(0,1500,PROT_EXEC|PROT_READ|PROT_WRITE,MAP_PRIVATE,<the fd>,0)
> 
> I've found that changing the permissions (chmod +x) on the file being
> mmap'ed makes the problem go away.
> 
> Is this the way things are supposed to work on XP?

This is a constraint of the underlying OS, yes.  The old implementation
of mmap used up to 1.5.18 didn't support PROT_EXEC at all, it was just
fake.  Since 1.5.19, PROT_EXEC mapping is now supported correctly, which
means, the underlying NT functions are called requesting PAGE_EXECUTE
protection.

But here's the problem.  To create file mappings with PAGE_EXECUTE
protection, the file must be opened with GENERIC_EXECUTE access. 
This is done internally in mmap, but it fails if the file doesn't
have the execute permission set.

Whether or not this behaviour is backed by SUSv3, I'm not sure.  SUSv3
states "if an implementation cannot support the combination of access
types specified by prot, the call to mmap() shall fail.", so here's one
situation in which the implementation can't support the combination of
access types specified by prot.


Corinna

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

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