Frage

If I map a page as write only:

int* mem_location = (int*)mmap(nullptr, getpagesize(), 
    PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);

cout << "Read @" << mem_location << ". This should segfault: " 
     << *mem_location << endl;

cout << "doesn't though??" << endl;

why doesn't it segfault on read?

War es hilfreich?

Lösung

See the man page:

On some hardware architectures (e.g., i386), PROT_WRITE implies PROT_READ.

You should not depend on this behavior.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top