Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: andreev <andreev@niisi.msk.ru>, Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Subject: Re: Strace doesn't work on linux-2.4.28 and later
Date: Mon, 07 Feb 2005 11:28:02 -0800	[thread overview]
Message-ID: <4207C142.6070804@avtrex.com> (raw)
In-Reply-To: <41FF876B.3070407@niisi.msk.ru>

andreev wrote:
> Hi, list.
> 
> We are using the latest kernel from mips-linux CVS and there is a 
> problem with ptrace.
> 
> When syscall with 5 or more arguments are traced, the fifth argument of 
> the syscall is overwritten
> by tracing code. This error causes problems with strace. For example, 
> you can't trace dynamically linked
> applications, because ld.so calls mmap which has 6 arguments.
> 

This patch broke it:

http://www.linux-mips.org/archives/linux-cvs/2004-11/msg00116.html

RCS file: /home/cvs/linux/arch/mips/kernel/Attic/scall_o32.S,v
retrieving revision 1.18.2.13
retrieving revision 1.18.2.14
diff -u -p -r1.18.2.13 -r1.18.2.14
--- linux/arch/mips/kernel/Attic/scall_o32.S	2004/04/26 15:06:02	1.18.2.13
+++ linux/arch/mips/kernel/Attic/scall_o32.S	2004/11/25 09:43:59	1.18.2.14
@@ -121,9 +121,9 @@ reschedule:

  trace_a_syscall:
  	SAVE_STATIC
-	sw	t2, PT_R1(sp)
+	sw	t2, PT_SCRATCH0(sp)
  	jal	syscall_trace
-	lw	t2, PT_R1(sp)
+	lw	t2, PT_SCRATCH0(sp)

  	lw	a0, PT_R4(sp)		# Restore argument registers
  	lw	a1, PT_R5(sp)

PT_SCRATCH0(sp) = 16(sp) which is where arg5 is stored.  This overwrites it.

In arch/mips/tools/offset.c we have:

	offset("#define PT_SCRATCH0 ", struct pt_regs, pad0[4]);
	offset("#define PT_SCRATCH1 ", struct pt_regs, pad0[5]);

I am thinking of testing a patch where I change them to:

	offset("#define PT_SCRATCH0 ", struct pt_regs, pad0[0]);
	offset("#define PT_SCRATCH1 ", struct pt_regs, pad0[1]);

Any needed argument registers are already saved in and restored from the 
regs array so overwriting the stack area reserved for them should be OK.

David Daney

  reply	other threads:[~2005-02-07 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-01 13:43 Strace doesn't work on linux-2.4.28 and later andreev
2005-02-07 19:28 ` David Daney [this message]
2005-02-07 19:39   ` David Daney
2005-02-07 21:08     ` Ralf Baechle
2005-02-07 21:20       ` David Daney
2005-02-07 21:17         ` Ralf Baechle

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=4207C142.6070804@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=andreev@niisi.msk.ru \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox