LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Chuck Ebbert <cebbert@redhat.com>
To: Andi Kleen <ak@suse.de>
Cc: Jeff Dike <jdike@addtoit.com>,
	patches@x86-64.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH x86 for review III] [12/29] x86_64: 32-bit ptrace mangles sixth system call argument
Date: Mon, 12 Feb 2007 17:04:54 -0500	[thread overview]
Message-ID: <45D0E486.9020104@redhat.com> (raw)
In-Reply-To: <20070212165132.6518713F45@wotan.suse.de>

Andi Kleen wrote:
> From: Jeff Dike <jdike@addtoit.com>
> The patch below copies %r9 (where the sixth argument has been
> stashed) into the RBP slot of pt_regs before syscall_trace_enter is
> called.  This fixes ptrace.
> 
> To allow a successful return to userspace, the original value of rbp
> must be restored.  This is done by storing the current value of rbp
> into the RBP slot of pt_regs before the RESTORE_REST.
> 
> --- linux.orig/arch/x86_64/ia32/ia32entry.S
> +++ linux/arch/x86_64/ia32/ia32entry.S
> @@ -148,11 +148,23 @@ sysenter_do_call:	
>  sysenter_tracesys:
>  	CFI_RESTORE_STATE
>  	SAVE_REST
> +	/*
> +	 * We need the 6th system call argument to be in regs->rbp at
> +	 * this point so that ptrace will see it.  It's in r9 now, so copy
> +	 * it to the rbp slot now.
> +	 */
> +	movq	%r9, RBP(%rsp)
>  	CLEAR_RREGS
>  	movq	$-ENOSYS,RAX(%rsp)	/* really needed? */
>  	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
>  	call	syscall_trace_enter
>  	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
> +	/*
> +	 * Now, we need the correct value of rbp to be restored.  It
> +	 * was never munged, so we can save it to the rbp slot and
> +	 * just have it restored.
> +	 */
> +	movq	%rbp, RBP(%rsp)
>  	RESTORE_REST
>  	movl	%ebp, %ebp
>  	/* no need to do an access_ok check here because rbp has been

Didn't we have problems with this exact approach before? This one was dropped
because it caused 32-bit programs to crash:
http://www2.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.13/2.6.13-mm2/broken-out/x86-64-ptrace-ia32-bp-fix.patch

See:
	http://lkml.org/lkml/2005/09/16/261

for the one I proposed instead.

And in any case doesn't cstar_tracesys() need the same fix?


  reply	other threads:[~2007-02-12 22:04 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-12 16:51 [PATCH x86 for review III] [1/29] i386: avoid gcc extension Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [2/29] i386: support Classic MediaGXm Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [3/29] i386: entry.S END/ENDPROC annotations Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [4/29] x86_64: clean up sparsemem memory_present call Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [5/29] i386: arch/i386/kernel/alternative.c should #include <asm/bugs.h> Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [6/29] i386: Remove unused kernel config option X86_XADD Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [7/29] x86_64: update IO-APIC dest field to 8-bit for xAPIC Andi Kleen
2007-02-12 19:49   ` Eric W. Biederman
2007-02-12 16:51 ` [PATCH x86 for review III] [8/29] x86_64: avoid warning message livelock Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [9/29] x86_64: Minor patch for compilation warning in x86_64 signal code Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [10/29] i386: don't include bugs.h Andi Kleen
2007-02-12 17:35   ` Jörn Engel
2007-02-12 18:33     ` Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [11/29] i386: add option to show more code in oops reports Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [12/29] x86_64: 32-bit ptrace mangles sixth system call argument Andi Kleen
2007-02-12 22:04   ` Chuck Ebbert [this message]
2007-02-12 22:26     ` Andi Kleen
2007-02-14 17:52     ` Jeff Dike
2007-02-12 16:51 ` [PATCH x86 for review III] [13/29] i386: geode configuration fixes Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [15/29] x86_64: Fix wrong gcc check in bitops.h Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [16/29] i386: Remove fastcall in paravirt.[ch] Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [17/29] x86: Add new CPUID bits for AMD Family 10 CPUs in /proc/cpuinfo Andi Kleen
2007-02-12 22:11   ` Chuck Ebbert
2007-02-12 22:23     ` Andi Kleen
2007-02-12 22:37       ` Chuck Ebbert
2007-02-12 22:38         ` Andi Kleen
2007-02-12 23:04           ` Chuck Ebbert
2007-02-12 16:51 ` [PATCH x86 for review III] [18/29] i386: Add L3 cache support to AMD CPUID4 emulation Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [19/29] x86: Enable NMI watchdog for AMD Family 0x10 CPUs Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [20/29] i386: Fix warning in microcode.c Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [21/29] i386: Fix warning in cpu initialization Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [23/29] x86: Don't require the vDSO for handling a.out signals Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [24/29] x86_64: -mm merge plans for 2.6.21 Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [25/29] i386: paravirt unhandled fallthrough Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [26/29] i386: Move mce_disabled to asm/mce.h Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [27/29] i386: Rename cpu_gdt_descr and remove extern declaration from smpboot.c Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [28/29] i386: Remove extern declaration from mm/discontig.c, put in header Andi Kleen
2007-02-12 16:51 ` [PATCH x86 for review III] [29/29] x86: Unify pcspeaker platform device code between i386/x86-64 Andi Kleen
2007-02-12 19:43 ` [PATCH x86 for review III] [1/29] i386: avoid gcc extension Jochen Voß
2007-02-12 20:18   ` Randy Dunlap
2007-02-13 15:11 ` Arnd Bergmann
2007-02-13 16:10   ` Randy Dunlap
2007-02-13 16:52     ` Andi Kleen

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=45D0E486.9020104@redhat.com \
    --to=cebbert@redhat.com \
    --cc=ak@suse.de \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@x86-64.org \
    --subject='Re: [PATCH x86 for review III] [12/29] x86_64: 32-bit ptrace mangles sixth system call argument' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).