Resent-Date: Wed, 6 Oct 1999 08:47:51 +0200 (MET DST)
Sender: labr@ubi.se
Date: Wed, 06 Oct 1999 08:47:45 +0200
From: lars brinkhoff <lars.brinkhoff@intermec.com>
X-Accept-Language: en
To: Roman Zippel <zippel@fh-brandenburg.de>
CC: linux-m68k@lists.linux-m68k.org
Subject: Re: PATCH: syscall change patch, part II
References: <Pine.GSO.4.10.9910051845520.11789-100000@zeus.fh-brandenburg.de>
Resent-From: linux-m68k@phil.uni-sb.de

Roman Zippel wrote:
> On Tue, 5 Oct 1999, lars brinkhoff wrote:
> > -                     if (addr == PT_ORIG_D0)
> > +                     if (addr == PT_ORIG_D0 &&
> > +                         (data >= NR_syscalls || data < 0))
> >                               goto out;
> Sorry, that I have to complain again :), but IMO that's the wrong
> behaviour, it should be possible to set PT_ORIG_D0 to any value and
> instead the traced syscall should fail with ENOSYS.

Perfectly fine with me, as long as I'm allowed to change
PT_ORIG_D0 at all!

In that case, I suggest this patch:

--- linux-2.3.16/arch/m68k/kernel/ptrace.c.orig	Tue Oct  5 14:20:38 1999
+++ linux-2.3.16/arch/m68k/kernel/ptrace.c	Wed Oct  6 08:39:10 1999
@@ -416,8 +416,6 @@
 
 			addr = addr >> 2; /* temporary hack. */
 			    
-			if (addr == PT_ORIG_D0)
-				goto out;
 			if (addr == PT_SR) {
 				data &= SR_MASK;
 				data <<= 16;
--- linux-2.3.16/arch/m68k/kernel/entry.S.orig	Mon Oct  4 15:33:19 1999
+++ linux-2.3.16/arch/m68k/kernel/entry.S	Wed Oct  6 08:45:51 1999
@@ -93,9 +93,13 @@
 	jbsr	SYMBOL_NAME(syscall_trace)
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
+	movel	#-ENOSYS,PT_D0(%sp)
+	movel	PT_ORIG_D0(%sp),%d2
+	cmpl	#NR_syscalls,%d2
+	jcc	1f
 	jbsr	@(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0)
 	movel	%d0,%sp@(PT_D0)		| save the return value
-	subql	#4,%sp			| dummy return address
+1:	subql	#4,%sp			| dummy return address
 	SAVE_SWITCH_STACK
 	jbsr	SYMBOL_NAME(syscall_trace)

