From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@osdl.org>
Cc: Christoph Hellwig <hch@lst.de>,
linux-kernel@vger.kernel.org,
William Lee Irwin III <wli@holomorphy.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] use ptrace_get_task_struct in various places
Date: Fri, 11 Nov 2005 00:27:11 +0100 [thread overview]
Message-ID: <20051110232711.GA18831@lst.de> (raw)
In-Reply-To: <20051107221149.08aa0820.akpm@osdl.org>
On Mon, Nov 07, 2005 at 10:11:49PM -0800, Andrew Morton wrote:
> Christoph Hellwig <hch@lst.de> wrote:
> >
> > The ptrace_get_task_struct() helper that I added as part of the ptrace
> > consolidation is usefull in variety of places that currently opencode
> > it. Switch them to the common helper.
>
> If we're going to export ptrace_get_task_struct() to the world it would be
> nice to document it too - things like returning zero and a NULL *childp is
> a little obscure.
done, patch below.
> In arch/ia64/ia32/sys_ia32.c this patch will cause PTRACE_TRACEME requests
> to be handled by ptrace_request()
you mean ptrace_get_task_struct?
> rather than by sys_ptrace(), which is a
> not-obviously-correct change.
sys_ptrace has the same code for it, in fact just about every ptrace
implementation uses ptrace_get_task_struct to handle that code,
but ptrace_get_task_struct can't be used by ia64 because some oddness
in the !PTRACE_TRACEME codepath.
> Was the omission of arch/ia64/kernel/ptrace.c:sys_ptrace() deliberate?
yes. it has some oddness about finding the 'right' task_struct of a
multi-threaded process.
Index: linux-2.6/kernel/ptrace.c
===================================================================
--- linux-2.6.orig/kernel/ptrace.c 2005-11-10 15:36:12.000000000 +0100
+++ linux-2.6/kernel/ptrace.c 2005-11-10 15:46:05.000000000 +0100
@@ -407,6 +407,23 @@
return ret;
}
+/**
+ * ptrace_get_task_struct -- grab a task struct reference for ptrace
+ * @long: ptrace request type
+ * @pid: process to work on
+ * @childp: task struct returned
+ *
+ * This function is a helper for ptrace implementations. It checks
+ * permissions and then grabs a task struct for use of the actual
+ * ptrace implementation. As a special case also handles PTRACE_TRACEME
+ * completely (as it's trivial and doesn't need a task_struct reference.
+ *
+ * The calling convention is a little bit odd: negative return value
+ * means failure, positive one sucess. But even when this function
+ * suceeds @childp can be NULL and the calling ptrace implementation
+ * should return sucessfully immediately afterwards. This is to support
+ * the PTRACE_TRACEME special case.
+ */
int ptrace_get_task_struct(long request, long pid, struct task_struct **childp)
{
struct task_struct *child;
next prev parent reply other threads:[~2005-11-10 23:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 5:30 [PATCH] use ptrace_get_task_struct in various places Christoph Hellwig
2005-11-08 6:11 ` Andrew Morton
2005-11-08 16:51 ` David S. Miller
2005-11-10 23:27 ` Christoph Hellwig [this message]
2005-11-11 0:00 ` Andrew Morton
2005-11-11 8:21 ` Christoph Hellwig
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=20051110232711.GA18831@lst.de \
--to=hch@lst.de \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=wli@holomorphy.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox