linux-um archives
 help / color / mirror / Atom feed
From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
To: Jeff Dike <jdike@addtoit.com>
Cc: BlaisorBlade <blaisorblade_spam@yahoo.it>,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] Re: Bad handling of invalif systemcalls
Date: Mon, 25 Oct 2004 17:21:16 +0200	[thread overview]
Message-ID: <417D19EC.6090809@fujitsu-siemens.com> (raw)
In-Reply-To: <417D1277.3090603@fujitsu-siemens.com>

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

Bodo Stroesser wrote:
> Jeff Dike wrote:
> 
>>
>> I would be tempted to #define SIGSYSCALL (SIGTRAP + 0x80) or something 
>> just
>> to make the +0x80 bit less magic-looking.
> 
> O.K. I defined it in signal_user.h, hope it's OK there. Consequently the
> definition is used in arch/um/kernel/ptrace.c to replace the 0x80 at the
> call to ptrace_notify().
> 
>>
>> In the SIGTRAP case, you might as well inline do_sigtrap.  One line 
>> functions
>> are pretty much a waste.
> 
> Sorry, I tried to inline it, but it failed to compile. At the moment 
> tracer.c
> contains functions without much knowledge about task structure only. 
> Without
> including the specific headers, inlining cannot be used.
> 
> So, attached you'll find the revised patches.
> 
> Bodo
Sorry, I missed one change. There still 0x80 is used in the first patch.
Thus, attached the final version (hopefully ...)

Bodo


[-- Attachment #2: patch-TRACESYSGOOD-1 --]
[-- Type: text/plain, Size: 2885 bytes --]

From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>

Patch 1/3 to implement usage of PTRACE_O_TRACESYSGOOD
This is necessary, to fix UMLs bad behavior when a process does
a systemcall with syscall-number less than 0.

Insert a check for availability and function of
  ptrace(PTRACE_SETOPTIONS,,,PTRACE_O_TRACESYSGOOD)
into the normal ptrace checks at startup.

Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
---

diff -puNr a/arch/um/include/signal_user.h b/arch/um/include/signal_user.h
--- a/arch/um/include/signal_user.h	2004-10-25 13:05:37.008823813 +0200
+++ b/arch/um/include/signal_user.h	2004-10-25 12:18:02.060620621 +0200
@@ -14,6 +14,8 @@ extern void set_handler(int sig, void (*
 extern int set_signals(int enable);
 extern int get_signals(void);
 
+#define SYSCALL_TRAP 0x80
+
 #endif
 
 /*
diff -puNr a/arch/um/kernel/process.c b/arch/um/kernel/process.c
--- a/arch/um/kernel/process.c	2004-10-25 13:05:37.008823813 +0200
+++ b/arch/um/kernel/process.c	2004-10-25 11:41:57.287362002 +0200
@@ -13,6 +13,7 @@
 #include <setjmp.h>
 #include <sys/time.h>
 #include <sys/ptrace.h>
+#include <linux/ptrace.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
 #include <asm/ptrace.h>
@@ -255,6 +256,9 @@ void __init check_ptrace(void)
 	printk("Checking that ptrace can change system call numbers...");
 	pid = start_ptraced_child(&stack);
 
+	if(ptrace(PTRACE_SETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
+		panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno);
+
 	while(1){
 		if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
 			panic("check_ptrace : ptrace failed, errno = %d", 
@@ -262,8 +266,8 @@ void __init check_ptrace(void)
 		CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 		if(n < 0)
 			panic("check_ptrace : wait failed, errno = %d", errno);
-		if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
-			panic("check_ptrace : expected SIGTRAP, "
+		if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|SYSCALL_TRAP)))
+			panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), "
 			      "got status = %d", status);
 		
 		syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET,
diff -puNr a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
--- a/arch/um/kernel/ptrace.c	2004-10-25 13:05:37.009823648 +0200
+++ b/arch/um/kernel/ptrace.c	2004-10-25 12:27:41.169919438 +0200
@@ -17,6 +17,7 @@
 #include "kern_util.h"
 #include "ptrace_user.h"
 #include "skas_ptrace.h"
+#include "signal_user.h"
 
 /*
  * Called by kernel/ptrace.c when detaching..
@@ -319,7 +320,7 @@ void syscall_trace(union uml_pt_regs *re
 	/* 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)
-				 ? 0x80 : 0));
+				 ? SYSCALL_TRAP : 0));
 
 	/*
 	 * this isn't the same as continuing with a signal, but it will do

      reply	other threads:[~2004-10-25 15:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-21 15:25 [uml-devel] Bad handling of invalif systemcalls Bodo Stroesser
2004-10-21 17:32 ` BlaisorBlade
2004-10-22  7:33   ` Bodo Stroesser
2004-10-21 22:09 ` [uml-devel] " Jeff Dike
2004-10-21 22:32   ` BlaisorBlade
2004-10-22  4:14     ` Jeff Dike
2004-10-22  8:14     ` Bodo Stroesser
2004-10-22  8:12   ` Bodo Stroesser
2004-10-22 21:02     ` Jeff Dike
2004-10-25 14:49   ` Bodo Stroesser
2004-10-25 15:21     ` Bodo Stroesser [this message]

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=417D19EC.6090809@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox