public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [small patch] ia64 find thread for user rbs address
@ 2006-11-16  7:54 bibo,mao
  2006-11-16  9:42 ` bibo,mao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bibo,mao @ 2006-11-16  7:54 UTC (permalink / raw)
  To: linux-ia64

hi,
  I encountered one problem when running ptrace test case, the
situation is this: traced process's syscall parameter needs to
be accessed, but for sys_clone system call with clone_flag
(CLONE_VFORK | CLONE_VM | SIGCHLD) parameter. this syscall's
parameter accessing result is wrong.
  The reason is that with clone_flag(CLONE_VFORK | CLONE_VM | SIGCHLD),
cloned thread's mm point is the same, but tgid is different.
without this patch find_thread_for_addr will return cloned thread,
but not the thread which call sys_clone syscall.

thanks
bibo,mao

--- 2.6.19-rc5.org/arch/ia64/kernel/ptrace.c	2006-11-16 16:23:31.000000000 +0800
+++ 2.6.19-rc5/arch/ia64/kernel/ptrace.c	2006-11-16 16:25:07.000000000 +0800
@@ -607,7 +607,7 @@ find_thread_for_addr (struct task_struct
 	 */
  	list_for_each_safe(this, next, &current->children) {
 		p = list_entry(this, struct task_struct, sibling);
-		if (p->mm != mm)
+		if (p->tgid != child->tgid)
 			continue;
 		if (thread_matches(p, addr)) {
 			child = p;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [small patch] ia64 find thread for user rbs address
  2006-11-16  7:54 [small patch] ia64 find thread for user rbs address bibo,mao
@ 2006-11-16  9:42 ` bibo,mao
  2006-11-17  7:12 ` Zhang, Yanmin
  2006-11-17  7:18 ` bibo,mao
  2 siblings, 0 replies; 4+ messages in thread
From: bibo,mao @ 2006-11-16  9:42 UTC (permalink / raw)
  To: linux-ia64

Tony,
please discard this patch. It can not fix completely. If ptrace
caller wants to access vforked child process's user rbs, there
will be problem.

thanks
bibo,mao

bibo,mao wrote:
> hi,
>   I encountered one problem when running ptrace test case, the
> situation is this: traced process's syscall parameter needs to
> be accessed, but for sys_clone system call with clone_flag
> (CLONE_VFORK | CLONE_VM | SIGCHLD) parameter. this syscall's
> parameter accessing result is wrong.
>   The reason is that with clone_flag(CLONE_VFORK | CLONE_VM | SIGCHLD),
> cloned thread's mm point is the same, but tgid is different.
> without this patch find_thread_for_addr will return cloned thread,
> but not the thread which call sys_clone syscall.
> 
> thanks
> bibo,mao
> 
> --- 2.6.19-rc5.org/arch/ia64/kernel/ptrace.c    2006-11-16 16:23:31.000000000 +0800
> +++ 2.6.19-rc5/arch/ia64/kernel/ptrace.c        2006-11-16 16:25:07.000000000 +0800
> @@ -607,7 +607,7 @@ find_thread_for_addr (struct task_struct
>          */
>         list_for_each_safe(this, next, &current->children) {
>                 p = list_entry(this, struct task_struct, sibling);
> -               if (p->mm != mm)
> +               if (p->tgid != child->tgid)
>                         continue;
>                 if (thread_matches(p, addr)) {
>                         child = p;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [small patch] ia64 find thread for user rbs address
  2006-11-16  7:54 [small patch] ia64 find thread for user rbs address bibo,mao
  2006-11-16  9:42 ` bibo,mao
@ 2006-11-17  7:12 ` Zhang, Yanmin
  2006-11-17  7:18 ` bibo,mao
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang, Yanmin @ 2006-11-17  7:12 UTC (permalink / raw)
  To: linux-ia64

On Thu, 2006-11-16 at 17:42, bibo,mao wrote:
> Tony,
> please discard this patch. It can not fix completely. If ptrace
> caller wants to access vforked child process's user rbs, there
> will be problem.
The patch is correct.

If ptracer wants to access vforked child process's user rbs,
find_thread_for_addr's first parameter, child, will points to
the vforked task_struct instead of vforker's.

> 
> thanks
> bibo,mao
> 
> bibo,mao wrote:
> > hi,
> >   I encountered one problem when running ptrace test case, the
> > situation is this: traced process's syscall parameter needs to
> > be accessed, but for sys_clone system call with clone_flag
> > (CLONE_VFORK | CLONE_VM | SIGCHLD) parameter. this syscall's
> > parameter accessing result is wrong.
> >   The reason is that with clone_flag(CLONE_VFORK | CLONE_VM | SIGCHLD),
> > cloned thread's mm point is the same, but tgid is different.
> > without this patch find_thread_for_addr will return cloned thread,
> > but not the thread which call sys_clone syscall.
> > 
> > thanks
> > bibo,mao
> > 
> > --- 2.6.19-rc5.org/arch/ia64/kernel/ptrace.c    2006-11-16 16:23:31.000000000 +0800
> > +++ 2.6.19-rc5/arch/ia64/kernel/ptrace.c        2006-11-16 16:25:07.000000000 +0800
> > @@ -607,7 +607,7 @@ find_thread_for_addr (struct task_struct
> >          */
> >         list_for_each_safe(this, next, &current->children) {
> >                 p = list_entry(this, struct task_struct, sibling);
> > -               if (p->mm != mm)
> > +               if (p->tgid != child->tgid)
> >                         continue;
> >                 if (thread_matches(p, addr)) {
> >                         child = p;
> > -

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [small patch] ia64 find thread for user rbs address
  2006-11-16  7:54 [small patch] ia64 find thread for user rbs address bibo,mao
  2006-11-16  9:42 ` bibo,mao
  2006-11-17  7:12 ` Zhang, Yanmin
@ 2006-11-17  7:18 ` bibo,mao
  2 siblings, 0 replies; 4+ messages in thread
From: bibo,mao @ 2006-11-17  7:18 UTC (permalink / raw)
  To: linux-ia64

Zhang, Yanmin wrote:
> On Thu, 2006-11-16 at 17:42, bibo,mao wrote:
>> Tony,
>> please discard this patch. It can not fix completely. If ptrace
>> caller wants to access vforked child process's user rbs, there
>> will be problem.
> The patch is correct.
> 
> If ptracer wants to access vforked child process's user rbs,
> find_thread_for_addr's first parameter, child, will points to
> the vforked task_struct instead of vforker's.
oh, I get messed with it. If ptracer wants to trace vforked child
process, then pid should be vforked process's pid but not vforker
parent process's pid. Then this parch is corrent.

thanks
bibo,mao
> 
>> thanks
>> bibo,mao
>>
>> bibo,mao wrote:
>>> hi,
>>>   I encountered one problem when running ptrace test case, the
>>> situation is this: traced process's syscall parameter needs to
>>> be accessed, but for sys_clone system call with clone_flag
>>> (CLONE_VFORK | CLONE_VM | SIGCHLD) parameter. this syscall's
>>> parameter accessing result is wrong.
>>>   The reason is that with clone_flag(CLONE_VFORK | CLONE_VM | SIGCHLD),
>>> cloned thread's mm point is the same, but tgid is different.
>>> without this patch find_thread_for_addr will return cloned thread,
>>> but not the thread which call sys_clone syscall.
>>>
>>> thanks
>>> bibo,mao
>>>
>>> --- 2.6.19-rc5.org/arch/ia64/kernel/ptrace.c    2006-11-16 16:23:31.000000000 +0800
>>> +++ 2.6.19-rc5/arch/ia64/kernel/ptrace.c        2006-11-16 16:25:07.000000000 +0800
>>> @@ -607,7 +607,7 @@ find_thread_for_addr (struct task_struct
>>>          */
>>>         list_for_each_safe(this, next, &current->children) {
>>>                 p = list_entry(this, struct task_struct, sibling);
>>> -               if (p->mm != mm)
>>> +               if (p->tgid != child->tgid)
>>>                         continue;
>>>                 if (thread_matches(p, addr)) {
>>>                         child = p;
>>> -
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-17  7:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-16  7:54 [small patch] ia64 find thread for user rbs address bibo,mao
2006-11-16  9:42 ` bibo,mao
2006-11-17  7:12 ` Zhang, Yanmin
2006-11-17  7:18 ` bibo,mao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox