kern/93396: dlopen crash with locked page

Zachary Loafman zachary.loafman at isilon.com
Fri Jan 4 18:10:04 PST 2008


The following reply was made to PR kern/93396; it has been noted by GNATS.

From: "Zachary Loafman" <zachary.loafman at isilon.com>
To: <bug-followup at FreeBSD.org>,
	<fabien.thomas at netasq.com>
Cc:  
Subject: Re: kern/93396: dlopen crash with locked page
Date: Fri, 4 Jan 2008 17:59:57 -0800

 Testcase that takes out any RTLD interaction, demonstrates the problem
 quickly, and works just fine if you take out the mlockall:
 
 --
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 
 #define EXIT_IF(__cond, __str) do { if (__cond) { perror(__str);
 exit(-1); } } while(0)
 
 int
 main()
 {
 	char name[] =3D "/tmp/pr93396.XXXXXX";
 	char buf[PAGE_SIZE];
 	int rc, fd;
 	char *map;
 
 	fd =3D mkstemp(name);
 	EXIT_IF(fd < 0, "mkstemp");
 
 	rc =3D write(fd, buf, PAGE_SIZE);
 	EXIT_IF(rc < PAGE_SIZE, "write");
 
 	rc =3D mlockall(MCL_CURRENT | MCL_FUTURE);
 	EXIT_IF(rc, "mlockall");
 
 	map =3D mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0);
 	EXIT_IF(!map, "mmap");
 
 	rc =3D mprotect(map, PAGE_SIZE, PROT_READ|PROT_WRITE);
 	EXIT_IF(rc, "mprotect");
 
 	*map =3D 'a';
 =09
 	return 0;
 }
 


More information about the freebsd-bugs mailing list