From: Juan Cespedes <cespedes@debian.org>
To: linux-kernel@vger.kernel.org
Subject: ptrace() bug
Date: Sun, 17 Feb 2002 15:56:15 +0100 [thread overview]
Message-ID: <20020217145615.GB2064@thehackers.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 888 bytes --]
Hi,
I am the author of "ltrace" and unfortunatelly it does not work in 2.4
kernels, due to a bug in the kernel. Unfortunately, I don't know when
did this behaviour started and what could have caused it...
Summary: if I use ptrace() witth a process that does fork(), and after
the fork I modify with PTRACE_POKETEXT some of the code in the parent,
the same modification is observed in the child.
I need to modify the .text in order to introduce breakpoints, but with
this bug ltrace does not work with any process which forks.
The attached little program shows the bug: the child should not see the
content of "sync" modified after it is alive.
Thanks for your help,
--
.+'''+. .+'''+. .+'''+. .+'''+. .+''
Juan Cespedes / \ / \ cespedes@debian.org
.+' `+...+' `+...+' `+...+' `+...+'
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 789 bytes --]
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ptrace.h>
#include <signal.h>
void
traced_process(void) {
if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
exit(1);
kill(getpid(), SIGCONT);
if (fork()) {
sleep(2);
/* printf("parent: *sync=%d\n", *(unsigned char*)sync); */
} else {
printf("child is alive (*sync=%d)\n", *(unsigned char*)sync);
sleep(1);
printf("child: *sync=%d\n", *(unsigned char*)sync);
}
exit(0);
}
int
main(void) {
pid_t pid;
int status;
int i=0;
pid = fork();
if (!pid) traced_process();
while(1) {
if (wait(&status)==-1) {
break;
}
printf("ptrace(PTRACE_POKETEXT, %d, sync, %d)...\n", pid, ++i);
ptrace(PTRACE_POKETEXT, pid, sync, i);
ptrace(PTRACE_SYSCALL, pid, 0, 0);
}
exit(0);
}
next reply other threads:[~2002-02-17 14:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-17 14:56 Juan Cespedes [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-10-16 0:12 ptrace bug Gian-Yan Xu
2001-10-15 17:04 ` Monty Vanderbilt
2001-10-16 9:52 ` Gian-Yan Xu
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=20020217145615.GB2064@thehackers.org \
--to=cespedes@debian.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®