linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@transmeta.com>
To: Michael Elizabeth Chastain <mec@shout.net>
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: PTRACE_POKEDATA on PROT_NONE hangs kernel
Date: Sun, 20 Sep 1998 23:17:27 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.3.96.980920231105.26419B-100000@penguin.transmeta.com> (raw)
In-Reply-To: <199809210152.UAA13294@duracef.shout.net>



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? 

		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/

      reply	other threads:[~1998-09-21  5:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-21  1:52 PTRACE_POKEDATA on PROT_NONE hangs kernel Michael Elizabeth Chastain
1998-09-21  6:17 ` Linus Torvalds [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.3.96.980920231105.26419B-100000@penguin.transmeta.com \
    --to=torvalds@transmeta.com \
    --cc=linux-kernel@vger.rutgers.edu \
    --cc=mec@shout.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).