All of lore.kernel.org
 help / color / mirror / Atom feed
From: vic <zandy@cs.wisc.edu>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Mike Coleman <mkc@mathdogs.com>,
	marcelo@conectiva.com.br, linux-kernel@vger.kernel.org,
	torvalds@transmeta.com, alan@lxorguk.ukuu.org.uk
Subject: Re: [PATCH] ptrace on stopped processes (2.4)
Date: Wed, 23 Jan 2002 11:58:56 -0600	[thread overview]
Message-ID: <m3sn8xkkyn.fsf@localhost.localdomain> (raw)
In-Reply-To: <m3adwc9woz.fsf@localhost.localdomain> <87g0632lzw.fsf@mathdogs.com> <m3advcq5jv.fsf@localhost.localdomain> <878zawvl1v.fsf@devron.myhome.or.jp>
In-Reply-To: <878zawvl1v.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Fri, 18 Jan 2002 04:23:24 +0900")

Now I see the problem with PTRACE_KILL.  Thanks for the example.

I'm looking into it.  I need to justify the quoted portion of the
patch or find a better way to get its effect.

In the meantime, the problem could be fixed by changing the
PTRACE_KILL implementation to call send_sig instead of setting
exit_code.  How does that strike people?

More generally, could someone explain to me why there are two
mechanisms for interprocess signaling within the kernel, exit_code and
send_sig?

Thanks,
Vic
> vic <zandy@cs.wisc.edu> writes:
>
>> From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>:
>> >> --- linux-2.4.16/kernel/ptrace.c	Wed Nov 21 16:43:01 2001
>> >> +++ linux-2.4.16.1/kernel/ptrace.c	Fri Dec 21 10:42:44 2001
>> >> @@ -89,8 +89,10 @@
>> >>  		SET_LINKS(task);
>> >>  	}
>> >>  	write_unlock_irq(&tasklist_lock);
>> >> -
>> >> -	send_sig(SIGSTOP, task, 1);
>> >> +	if (task->state != TASK_STOPPED)
>> >> +		send_sig(SIGSTOP, task, 1);
>> >> +	else
>> >> +		task->exit_code = SIGSTOP;
>> >>  	return 0;
>> >>  
>> >>  bad:
>> >
>> > It seems that trace is started in the place different from
>> > usual. Then, I think PTRACE_KILL doesn't work.
>> 
>> I don't agree, it seems to work for me.
>
> I tested the following on linux-2.4.16 + your_patch:
>
> #include <stdio.h>
> #include <signal.h>
> #include <sys/types.h>
> #include <sys/wait.h>
> #include <sys/ptrace.h>
> #include <unistd.h>
>
> int main(int argc, char *argv[])
> {
> 	pid_t pid;
> 	int ret, status;
>
> 	pid = fork();
> 	if (pid == -1)
> 		exit(1);
> 	if (pid == 0) {
> 		raise(SIGSTOP);
> 		while (1)
> 			;
> 		_exit(1);
> 	}
>
> 	ret = waitpid(pid, &status, WUNTRACED);
> 	if (ret == -1) {
> 		perror("waitpid (1)");
> 		exit(1);
> 	}
>
> 	ret = ptrace(PTRACE_ATTACH, pid, NULL, NULL);
> 	if (ret == -1) {
> 		perror("PTRACE_ATTACH");
> 		exit(1);
> 	}
> 	ret = waitpid(pid, &status, 0);
> 	if (ret == -1) {
> 		perror("waitpid (2)");
> 		exit(1);
> 	}
> 	ret = ptrace(PTRACE_KILL, pid, NULL, NULL);
> 	if (ret == -1) {
> 		perror("PTRACE_KILL");
> 		exit(1);
> 	}
>
> 	return 0;
> }
>
> Test result:
>
>     hirofumi@devron (ptrace)[1111]$ ps ax|grep ptrace
>       688 tty1     S      0:00 grep ptrace
>     hirofumi@devron (ptrace)[1112]$ ls
>     ptrace  ptrace.c
>     hirofumi@devron (ptrace)[1113]$ ./ptrace
>     hirofumi@devron (ptrace)[1114]$ ps ax|grep ptrace
>       691 tty1     R      0:04 ./ptrace
>       693 tty1     S      0:00 grep ptrace
>     hirofumi@devron (ptrace)[1115]$
>
> Do I misunderstand something?
> -- 
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2002-01-23 17:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-21 19:53 [PATCH] ptrace on stopped processes (2.4) vic
2001-12-21 23:19 ` Jeff Dike
2001-12-22  3:56 ` OGAWA Hirofumi
2001-12-22 17:38 ` Mike Coleman
2002-01-17 16:57   ` vic
2002-01-17 19:23     ` OGAWA Hirofumi
2002-01-23 17:58       ` vic [this message]
2002-01-23 22:14         ` OGAWA Hirofumi
2002-01-23 22:29           ` vic
2002-01-24  1:41             ` OGAWA Hirofumi
2002-01-21  3:09     ` Mike Coleman
2002-01-28 20:15       ` vic
2002-03-19  3:59         ` vic
  -- strict thread matches above, loose matches on Subject: below --
2003-03-17 21:24 Rajesh Rajamani
2003-03-24  4:09 ` Daniel Jacobowitz
2003-03-24  6:24   ` raj
2003-03-24 15:05     ` Daniel Jacobowitz
2003-03-25 13:48       ` Werner Almesberger
2003-03-25 13:58         ` Daniel Jacobowitz
2003-03-25 14:53           ` Werner Almesberger

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=m3sn8xkkyn.fsf@localhost.localdomain \
    --to=zandy@cs.wisc.edu \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=mkc@mathdogs.com \
    --cc=torvalds@transmeta.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.