From: Andrew Morton <akpm@linux-foundation.org>
To: Roland McGrath <roland@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Oleg Nesterov <oleg@tv-sign.ru>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] ptrace children revamp
Date: Thu, 17 Jul 2008 00:30:50 -0700 [thread overview]
Message-ID: <20080717003050.87f96ab0.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080717071322.B80F315411D@magilla.localdomain>
On Thu, 17 Jul 2008 00:13:22 -0700 (PDT) Roland McGrath <roland@redhat.com> wrote:
> ptrace no longer fiddles with the children/sibling links, and the
> old ptrace_children list is gone. Now ptrace, whether of one's own
> children or another's via PTRACE_ATTACH, just uses the new ptraced
> list instead.
>
> There should be no user-visible difference that matters. The only
> change is the order in which do_wait() sees multiple stopped
> children and stopped ptrace attachees. Since wait_task_stopped()
> was changed earlier so it no longer reorders the children list, we
> already know this won't cause any new problems.
>
> ...
>
> +repeat:
> task_lock(current);
> if (!(current->ptrace & PT_PTRACED)) {
> + /*
> + * See ptrace_attach() comments about the locking here.
> + */
/*
* Nasty, nasty.
*
* We want to hold both the task-lock and the
* tasklist_lock for writing at the same time.
* But that's against the rules (tasklist_lock
* is taken for reading by interrupts on other
* cpu's that may have task_lock).
*/
> + unsigned long flags;
> + if (!write_trylock_irqsave(&tasklist_lock, flags)) {
> + task_unlock(current);
> + do {
> + cpu_relax();
> + } while (!write_can_lock(&tasklist_lock));
> + goto repeat;
> + }
> +
hm, copying this code didn't do much to improve the world.
Is there any prospect of "fixing" this somehow?
Perhaps this code should be pulled up into a separate function, not
that this will help things a lot.
> ret = security_ptrace(current->parent, current,
> PTRACE_MODE_ATTACH);
> +
> /*
> * Set the ptrace bit in the process ptrace flags.
> + * Then link us on our parent's ptraced list.
> */
> - if (!ret)
> + if (!ret) {
> current->ptrace |= PT_PTRACED;
> + __ptrace_link(current, current->real_parent);
> + }
> +
> + write_unlock_irqrestore(&tasklist_lock, flags);
> }
> task_unlock(current);
> return ret;
next prev parent reply other threads:[~2008-07-17 7:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 7:11 [PATCH 0/5] ptrace & wait cleanup Roland McGrath
2008-07-17 7:12 ` [PATCH 1/4] do_wait reorganization Roland McGrath
2008-07-17 7:13 ` [PATCH 2/4] ptrace children revamp Roland McGrath
2008-07-17 7:30 ` Andrew Morton [this message]
2008-07-17 7:34 ` Roland McGrath
2008-07-17 7:13 ` [PATCH 3/4] do_wait: return security_task_wait() error code in place of -ECHILD Roland McGrath
2008-07-17 9:23 ` James Morris
2008-07-17 7:14 ` [PATCH 4/4] fix dangling zombie when new parent ignores children Roland McGrath
-- strict thread matches above, loose matches on Subject: below --
2008-05-06 0:32 [PATCH 1/4] do_wait reorganization Roland McGrath
2008-05-06 0:33 ` [PATCH 2/4] ptrace children revamp Roland McGrath
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=20080717003050.87f96ab0.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.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
Powered by JetHome