Re: PTRACE_POKEDATA on PROT_NONE hangs kernel

Michael Elizabeth Chastain (mec@shout.net)
Tue, 22 Sep 1998 08:44:58 -0500


I figured another way to create a _PAGE_PROTNONE pte that is mapped to
a physical page and has real data in it:

#include <sys/types.h>
#include <sys/mman.h>

#include <stdio.h>
#include <string.h>

int main( )
{
char * buf = mmap( 0, 4096, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
strcpy( buf, "hello world" );
mprotect( buf, 4096, PROT_NONE );
/* buf has _PAGE_PROTNONE here */
mprotect( buf, 4096, PROT_READ );
printf( "%s\n", buf );
return 0;
}

This program works on 2.1.122, but once again, I'm suspicious of the
code in mm/memory.c. What happens if my program sleeps here and this
page gets swapped out? Now I have a _PAGE_PROTNONE page that can change
between the "present" and "not present" states.

The rule "a _PAGE_PROTNONE pte is always pte_present" looks inadequate
here.

Michael Elizabeth Chastain
<mailto:mec@shout.net>
"love without fear"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/