Re: PTRACE_POKEDATA on PROT_NONE hangs kernel

Linus Torvalds (torvalds@transmeta.com)
Tue, 22 Sep 1998 09:33:53 -0700 (PDT)


On Tue, 22 Sep 1998, Michael Elizabeth Chastain wrote:
> I figured another way to create a _PAGE_PROTNONE pte that is mapped to
> a physical page and has real data in it:

Yes, this is quite normal. People use PROT_NONE for persistent data stuff
etc, and it's very much meant to exist "underneath" the system - the page
is still there, it's just unreadable and unwritable.

> 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.

If the page gets swapped out, everything still works correctly.

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

No, that rule is fine. It means, for example, that the swap-out logic will
consider it present, write it out, and then replace it with a swapped-out
entry. Then, when somebody touches the page, the swap-in mechanism will
page it in again, and get the protection from the vma list, and the
_PAGE_PROTNONE thing will become active again.

The _only_ problem is when you use ptrace(), because that really goes past
both the normal hardware memory management, and the normal kernel mm
layer. It accesses the page directly, and that code has had bugs before,
exactly because it needs to do "dirty" things that cannot normally happen.

Linus

-
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/