Messages in this thread | | | From | Kyle Moffett <> | Subject | Re: Testing PROT_NONE and other protections, and a surprise | Date | Thu, 1 Jul 2004 00:59:36 -0400 |
| |
On Jul 01, 2004, at 00:11, Jamie Lokier wrote: > Can you confirm in a simple way that mapping a file, or some anonymous > memory, without PROT_READ, really isn't writable under MacOS X? Can > you confirm it with a word write, if that would be relevant?
I hope I didn't make some stupid mistake in my program, but here it is, and here are my results. I'll probably go file a bug with Apple now :-D
zeus:~ kylemoffett$ cat >testp.c #include <sys/types.h> #include <sys/mman.h>
#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/mman.h>
int main(int argc, char **argv) { long x = 100; void *mem; fprintf(stderr,"Starting...\n"); mem = mmap(0,4096,PROT_WRITE,MAP_ANON|MAP_SHARED,-1,0); fprintf(stderr,"Mapped memory!\n"); if (mem == 0) return 1; fprintf(stderr,"Address is %lx\n",(unsigned long)mem); ((long *)mem)[1] = x; fprintf(stderr,"Done!!!\n"); return 0; } ^D zeus:~ kylemoffett$ gcc testp.c -o testp zeus:~ kylemoffett$ ./testp Starting... Mapped memory! Address is 4000 Bus error zeus:~ kylemoffett$
Cheers, Kyle Moffett
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |