From: Andreas Schwab <schwab@suse.de>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] Fix error checking in sys32_ptrace
Date: Thu, 27 Mar 2003 15:02:48 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590723705335@msgid-missing> (raw)
This fixes sys32_ptrace to use ptrace_check_attach, so that it
automatically inherits all future enhancements there.
Andreas.
--- linux-2.4.19/arch/ia64/ia32/sys_ia32.c.~1~ 2003-03-20 16:33:21.000000000 +0100
+++ linux-2.4.19/arch/ia64/ia32/sys_ia32.c 2003-03-21 22:27:32.000000000 +0100
@@ -3076,26 +3076,23 @@ sys32_ptrace (int request, pid_t pid, un
ret = -ESRCH;
read_lock(&tasklist_lock);
child = find_task_by_pid(pid);
+ if (child)
+ get_task_struct(child);
read_unlock(&tasklist_lock);
if (!child)
goto out;
ret = -EPERM;
if (pid = 1) /* no messing around with init! */
- goto out;
+ goto out_tsk;
if (request = PTRACE_ATTACH) {
ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack);
- goto out;
- }
- ret = -ESRCH;
- if (!(child->ptrace & PT_PTRACED))
- goto out;
- if (child->state != TASK_STOPPED) {
- if (request != PTRACE_KILL)
- goto out;
+ goto out_tsk;
}
- if (child->p_pptr != current)
- goto out;
+
+ ret = ptrace_check_attach(child, request = PTRACE_KILL);
+ if (ret < 0)
+ goto out_tsk;
switch (request) {
case PTRACE_PEEKTEXT:
@@ -3105,12 +3102,12 @@ sys32_ptrace (int request, pid_t pid, un
ret = put_user(value, (unsigned int *) A(data));
else
ret = -EIO;
- goto out;
+ goto out_tsk;
case PTRACE_POKETEXT:
case PTRACE_POKEDATA: /* write the word at location addr */
ret = ia32_poke(regs, child, addr, data);
- goto out;
+ goto out_tsk;
case PTRACE_PEEKUSR: /* read word at addr in USER area */
ret = -EIO;
@@ -3185,6 +3182,8 @@ sys32_ptrace (int request, pid_t pid, un
break;
}
+ out_tsk:
+ free_task_struct(child);
out:
unlock_kernel();
return ret;
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next reply other threads:[~2003-03-27 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-27 15:02 Andreas Schwab [this message]
2003-03-27 20:49 ` [Linux-ia64] Fix error checking in sys32_ptrace David Mosberger
2003-04-16 23:05 ` Bjorn Helgaas
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=marc-linux-ia64-105590723705335@msgid-missing \
--to=schwab@suse.de \
--cc=linux-ia64@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 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.