Re: Testing PROT_NONE and other protections, and a surprise
From: Jamie Lokier
Date: Thu Jul 01 2004 - 07:41:13 EST
Kyle Moffett 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.
Thanks for testing, Kyle.
It looks fine, although this is wrong:
> mem = mmap(0,4096,PROT_WRITE,MAP_ANON|MAP_SHARED,-1,0);
> ...
> if (mem == 0) return 1;
The error code is -1, aka. MAP_FAILED.
> Starting...
> Mapped memory!
> Address is 4000
That's a surprisingly low address.
> Bus error
Phew, I'm glad I decided to catch SIGBUS in the test program at the
last moment...
That's a historical BSD-ism. They can't change it now, because
programs do trap and check for SIGBUS on that platform for protection
violations.
> I'll probably go file a bug with Apple now :-D
It might be a generic *BSD bug (for whatever value of * is used by MacOS X).
That would be interesting to know -- anyone here running *BSD on PPC
or any other architecture to test?
Of course it's an Apple bug as well :)
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/