From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0; T312461) Description of problem: If you are debugging a program and modify read only pages (by setting a breakpoint, for example), then the modified pages are now writable by the user process being debugged as well. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Compile attached bug.c program (with -g) 2. Run it and watch it segfault 3. Now run gdb on the program. 4. Set a breakpoint at *&main 5. Let the program run to the breakpoint, then continue it. 6. Watch the program run with no errors and overwrite &main. Actual Results: Program does not segfault. Expected Results: Program should segfault. Just because it is running under the debugger, read/execute pages should not become writable. By the way: The /proc address map info still shows the page as read/execute even though it really is writable after you set the breakpoint. Additional info: Here is the bug.c source code (its small): #include <stdio.h> int main(int argc, char ** argv) { int * mainprog = ((int *)(void *)&main); printf("Main program starts at %#x\n", mainprog); printf("First word looks like 0x%08x\n", *mainprog); printf("About to try writing on it...\n"); fflush(stdout); *mainprog = 0xdeadbeef; printf("First word now looks like 0x%08x\n", *mainprog); fflush(stdout); return 0; }
Since ptrace changes quite a bit per kernel version, could you specify which kernel version(s) you have tested ?
I tried several different linux systems, and it failed on all of them (including a 2.4.18 kernel we have some custom mods in). The redhat 7.1 system it failed on first is running 2.4.9-21.
Thanks for the bug report. However, Red Hat no longer maintains this version of the product. Please upgrade to the latest version and open a new bug if the problem persists. The Fedora Legacy project (http://fedoralegacy.org/) maintains some older releases, and if you believe this bug is interesting to them, please report the problem in the bug tracker at: http://bugzilla.fedora.us/