From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
To: BlaisorBlade <blaisorblade_spam@yahoo.it>
Cc: user-mode-linux-devel@lists.sourceforge.net, jdike@addtoit.com
Subject: Re: [uml-devel] Re: [patch 1/1] SYSEMU: avoid intercepting syscall on return when using SYSCALL again.
Date: Wed, 27 Oct 2004 16:21:49 +0200 [thread overview]
Message-ID: <417FAEFD.8070805@fujitsu-siemens.com> (raw)
In-Reply-To: <41793409.70001@fujitsu-siemens.com>
Bodo Stroesser wrote:
> BlaisorBlade wrote:
>
>> Yes - I forgot it. Does the revised version work? My version did not -
>> it failed the startup test. In fact, PTRACE_CONT is called in the
>> startup test (which fails). I'm recompiling and testing.
>
> Yes. My system works very fine with it.
Now I've tested with host 2.6.9 and skas3.v6 patch. I adapted my latest
patch and had problems with singlestepping on UML in SKAS with sSYSEMU.
It looped receiving SIGTRAPs without moving forward. EIP of the traced
process was the same for all SIGTRAPs.
What's missing is to handle switching from PTRACE_SYSCALL_EMU to
PTRACE_SINGLESTEP in a way very similar to what is done for the change
from PTRACE_SYSCALL_EMU to PTRACE_SYSCALL_TRACE.
Here is the corresponding patch.
Bodo
P.S.: When testing UML 2.6.9 in SAKS on host 2.6.9, UML didn't terminate
after init 0. kernel-process and userspace-process didn't go out at the end.
ps aux shows S+ for kernel and T+ for userspace. I only could kill them with
kill -9 kernel-pid. After having done this, the host can't unmount its
filesystems: "in use". Doesn't that look like a host-bug?
---
--- a/arch/i386/kernel/ptrace.c 2004-10-27 10:13:55.515622561 +0200
+++ b/arch/i386/kernel/ptrace.c 2004-10-27 10:21:01.958150451 +0200
@@ -367,16 +367,21 @@ asmlinkage int sys_ptrace(long request,
ret = -EIO;
if ((unsigned long) data > _NSIG)
break;
+ /* If we came here with PTRACE_SYSEMU and now continue with
+ * PTRACE_SYSCALL, entry.S used to intercept the syscall return. But it
+ * shouldn't!
+ * So we don't clear TIF_SYSCALL_EMU, which is always unused in this
+ * special case, to remember, we came from SYSEMU. That flag
+ * will be cleared by do_syscall_trace().
+ */
if (request == PTRACE_SYSEMU) {
set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
- }
- else {
+ } else if (request == PTRACE_CONT) {
clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
}
if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
- }
- else {
+ } else {
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
}
clear_tsk_thread_flag(child, TIF_SINGLESTEP);
@@ -415,7 +420,6 @@ asmlinkage int sys_ptrace(long request,
ret = -EIO;
if ((unsigned long) data > _NSIG)
break;
- clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
if ((child->ptrace & PT_DTRACE) == 0) {
/* Spurious delayed TF traps may occur */
@@ -589,7 +593,7 @@ out:
__attribute__((regparm(3)))
int do_syscall_trace(struct pt_regs *regs, int entryexit)
{
- int is_sysemu;
+ int is_sysemu, is_systrace, is_singlestep;
if (unlikely(current->audit_context)) {
if (!entryexit)
audit_syscall_entry(current, regs->orig_eax,
@@ -599,17 +603,26 @@ int do_syscall_trace(struct pt_regs *reg
audit_syscall_exit(current, regs->eax);
}
is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
+ is_systrace = test_thread_flag(TIF_SYSCALL_TRACE);
+ is_singlestep = test_thread_flag(TIF_SINGLESTEP);
- if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
- !test_thread_flag(TIF_SINGLESTEP) &&
- !is_sysemu)
+ if (!is_systrace && !is_sysemu && !is_singlestep )
return 0;
+ /* We can detect the case of coming from PTRACE_SYSEMU and now
+ * running with PTRACE_SYSCALL, by TIF_SYSCALL_EMU being set
+ * additionally.
+ * If so let's reset the flag and return without action.
+ */
+ if (is_sysemu && (is_systrace || is_singlestep)) {
+ clear_thread_flag(TIF_SYSCALL_EMU);
+ return 0;
+ }
if (!(current->ptrace & PT_PTRACED))
return 0;
/* the 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) &&
- !test_thread_flag(TIF_SINGLESTEP) ? 0x80 : 0));
+ !is_singlestep ? 0x80 : 0));
/*
* this isn't the same as continuing with a signal, but it will do
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2004-10-27 14:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-21 23:18 [uml-devel] [patch 1/1] SYSEMU: avoid intercepting syscall on return when using SYSCALL again blaisorblade_spam
2004-10-22 0:37 ` BlaisorBlade
2004-10-22 9:22 ` [uml-devel] " Bodo Stroesser
2004-10-22 16:14 ` BlaisorBlade
2004-10-22 16:23 ` Bodo Stroesser
2004-10-27 14:21 ` Bodo Stroesser [this message]
2004-10-28 23:04 ` Blaisorblade
2004-10-28 23:36 ` Bodo Stroesser
[not found] ` <200410290200.46907.blaisorblade_spam@yahoo.it>
2004-10-29 1:19 ` Bodo Stroesser
2004-10-29 7:51 ` Gerd Knorr
2004-10-29 13:09 ` Blaisorblade
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=417FAEFD.8070805@fujitsu-siemens.com \
--to=bstroesser@fujitsu-siemens.com \
--cc=blaisorblade_spam@yahoo.it \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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.