delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/14/09:52:32

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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: Tue, 14 Jan 2003 09:58:03 -0500
From: Jason Tishler <jason AT tishler DOT net>
Subject: Re: Cygwin vsFTPd porting issues
In-reply-to: <20030113225920.GA1373@cygbert.vinschen.de>
To: cygwin AT cygwin DOT com
Mail-followup-to: cygwin AT cygwin DOT com
Message-id: <20030114145803.GA1692@tishler.net>
MIME-version: 1.0
User-Agent: Mutt/1.4i
References: <20030113143624 DOT GF1012 AT tishler DOT net>
<20030113145517 DOT GI16529 AT cygbert DOT vinschen DOT de>
<20030113202110 DOT GG1012 AT tishler DOT net> <20030113225920 DOT GA1373 AT cygbert DOT vinschen DOT de>

--Boundary_(ID_zg+QZHwnGjm6sMPBIqYtZQ)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

Corinna,

On Mon, Jan 13, 2003 at 11:59:20PM +0100, Corinna Vinschen wrote:
> I guess it's actually a fault in Cygwin's mmap() implementation but I
> don't see the cause so far.  I'd greatly appreciate if you could put
> some effort into analyzing the problem.

Sure.  I'll do whatever I can to help.

> Could you send a fragment of the strace output grep'd for
> 'm\(un\)*map' in the meantime?

Instead of the above, I have attached for a small testcase, mmap-test.c,
that reproduces the problem.  When mmap-test is run, you should get
something like the following output:

    $ mmap-test
    190 [main] mmap-test 2592 fixup_mmaps_after_fork: ReadProcessMemory failed for MAP_PRIVATE address 0x640000, Win32 error 299
C:\home\jt\src\vsftpd-1.1.3\test\mmap-test.exe: *** recreate_mmaps_after_fork_failed
      6 [main] mmap-test 660 sync_with_child: child 2592(0xF4) died before initialization with status code 0x1
   7139 [main] mmap-test 660 sync_with_child: *** child state child loading dlls

Thanks,
Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

--Boundary_(ID_zg+QZHwnGjm6sMPBIqYtZQ)
Content-type: text/plain; charset=us-ascii; NAME=mmap-test.c
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=mmap-test.c

/*
 * Taken from Very Secure FTPd
 * Licence: GPL
 * Author: Chris Evans
 * Modified: Jason Tishler
 *
 * Here are some routines providing the (possibly silly) concept of a secure
 * buffer. A secure buffer may not be overflowed. A single byte overflow
 * will cause the program to safely terminate.
 */

#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

void
vsf_secbuf_alloc(char** p_ptr, unsigned int size)
{
  unsigned int page_offset;
  unsigned int round_up;
  char* p_mmap;
  char* p_no_access_page;
  unsigned int page_size = getpagesize();

  /* Round up to next page size */
  page_offset = size % page_size;
  if (page_offset)
  {
    unsigned int num_pages = size / page_size;
    num_pages++;
    round_up = num_pages * page_size;
  }
  else
  {
    /* Allocation is on a page-size boundary */
    round_up = size;
  }
  /* Add on another two pages to make inaccessible */
  round_up += page_size * 2;

  p_mmap = mmap(0, round_up, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON,
		-1, 0);
  /* Map the first and last page inaccessible */
  p_no_access_page = p_mmap + round_up - page_size;
  mprotect(p_no_access_page, page_size, PROT_NONE);
  p_no_access_page = p_mmap;
  mprotect(p_no_access_page, page_size, PROT_NONE);

  p_mmap += page_size;
  if (page_offset)
  {
    p_mmap += (page_size - page_offset);
  }
  *p_ptr = p_mmap;
}

int
main()
{
  char* p_sec_buf = 0;
  pid_t pid =0;

  vsf_secbuf_alloc(&p_sec_buf, 2000);
  pid = fork();
  if (pid > 0)
    wait(0);

  exit(0);
}


--Boundary_(ID_zg+QZHwnGjm6sMPBIqYtZQ)
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--Boundary_(ID_zg+QZHwnGjm6sMPBIqYtZQ)--

- Raw text -


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