Mail Archives: cygwin/2003/01/14/09:52:32
--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 -