[lkml]   [1998]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: PTRACE_POKEDATA on PROT_NONE hangs kernel

On Sun, 20 Sep 1998, Michael Elizabeth Chastain wrote:
> First of all, if anyone else out there knows about the recent
> _PAGE_PROTNONE optimization, could you write to me please?
> I need to talk to you, if only for background information.

It's not an optimization. It's there to make things work. It essentially
has to be done that way due to the less than satisfactory intel page table
setup (there's no way to say "this page is present, but cannot be accessed
from user or kernel mode", we actuall yhave to turn off the present bit
and then use a separate bit (the _PAGE_PROTNONE bit) to keep track of the
fact that the page _is_ actually present.

> There are two pte tests in put_long:
> /* arch/i386/kernel/ptrace.c: put_long */
> pgtable = pte_offset(pgmiddle, addr);
> if (!pte_present(*pgtable)) {
> handle_mm_fault(tsk, vma, addr, 1);
> goto repeat;
> }

Right. The above pages it in if it isn't present. In this case, it does
nothing, because the page _is_ present (as far as the kernel is
concerned), it's just marked non-present as far as hardware is concerned
in order to get the right PROT_NONE permissions.

> page = pte_page(*pgtable);
> if (!pte_write(*pgtable)) {
> handle_mm_fault(tsk, vma, addr, 1);
> goto repeat;
> }

Ahhah. Ok, this is the buggy one. The problem is that we _should_ do a
"handle_mm_fault()" if it isn't writable, but we have no current knowledge
of that as is..

Ok, I have a simple fix, I think.

Fix for the above, take two:

- if (!pte_write(*pgtable)) {
+ if (!pte_dirty(*pgtable)) {
handle_mm_fault(tsk, vma, addr, 1);
goto repeat;

The above should correctly do the proper mm fault handling whenever the
page hasn't been written to before.

Does that finally fix it for you for all cases?


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:44    [W:0.030 / U:5.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site