[lkml]   [2000]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] Ptrace problem in 2.4.0-test7
There is a generic (i.e. not architecture specific) problem in the
ptrace code in 2.4.0, which I have seen on on x86.

If a debugger attempts to use a ptrace call to read from a process'
BSS page which has not yet been modified the ptrace call fails (with
EIO) rather than returning zero bytes as it should.

The reason is that in this case the process will either already have
the (one and only) ZERO_PAGE mapped, or the call to handle_mm_fault in
access_one_page will cause the ZERO_PAGE to be mapped. However, the
ZERO_PAGE has the status PageReserved. Therefore access_one_page
believes that user level access to the page is forbidden, and fails
the access via ptrace.

Here's a patch which fixes the problem by explicitly allowing
access_one_page to use the ZERO_PAGE.

--- kernel/ptrace.c Fri Sep 8 09:01:14 2000
+++ kernel/ptrace-2.4.0-test7.c Fri Sep 8 08:56:13 2000
@@ -44,7 +44,7 @@
if (write && (!pte_write(*pgtable) || !pte_dirty(*pgtable)))
goto fault_in_page;
page = pte_page(*pgtable);
- if ((!VALID_PAGE(page)) || (PageReserved(page) && page != ZERO_PAGE(addr))
+ if ((!VALID_PAGE(page)) || PageReserved(page))
return 0;
flush_cache_page(vma, addr);

p.s. Please CC me on any replies since I am not currently subscribed
to the linux-kernel list, and I'm out all next week so don't want to
subscribe right now :-(


-- Jim

James Cownie <>
Etnus, LLC. +44 117 9071438

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 12:38    [W:0.048 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site