LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com> To: Andrew Morton <akpm@linux-foundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Subject: [PATCH] x86_64 ptrace orig_ax on ia32 task Date: Fri, 7 Mar 2008 14:56:02 -0800 (PST) [thread overview] Message-ID: <20080307225602.6491B26F990@magilla.localdomain> (raw) In-Reply-To: Roland McGrath's message of Thursday, 28 February 2008 19:57:07 -0800 <20080229035707.EAE862700FD@magilla.localdomain> This makes 64-bit ptrace calls setting the 64-bit orig_ax field for a 32-bit task sign-extend the low 32 bits up to 64. This matches what a 64-bit debugger expects when tracing a 32-bit task. This follows on my "x86_64 ia32 syscall restart fix". This didn't matter until that was fixed. The debugger ignores or zeros the high half of every register slot it sets (including the orig_rax pseudo-register) uniformly. It expects that the setting of the low 32 bits always has the same meaning as a 32-bit debugger setting those same 32 bits with native 32-bit facilities. This never arose before because the syscall restart check never matched any -ERESTART* values due to lack of sign extension. Before that fix, even 32-bit ptrace setting orig_eax to -1 failed to trigger the restart check anyway. So this was never noticed as a regression of 64-bit debuggers vs 32-bit debuggers on the same 64-bit kernel. Signed-off-by: Roland McGrath <roland@redhat.com> --- arch/x86/kernel/ptrace.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index f8eed1b..92b44e1 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -322,6 +322,20 @@ static int putreg(struct task_struct *child, case offsetof(struct user_regs_struct, flags): return set_flags(child, value); +#ifdef CONFIG_IA32_EMULATION + case offsetof(struct user_regs_struct, orig_ax): + /* + * For a 32-bit task, setting only the low 32 bits and + * leaving the high bits untouched (all 0) has the same + * effect as setting those bits via 32-bit ptrace would. + * This means sign-extending an orig_eax of -1, which + * here is an orig_rax of (u32)-1. + */ + if (test_tsk_thread_flag(child, TIF_IA32)) + value = (long) (s32) value; + break; +#endif + #ifdef CONFIG_X86_64 case offsetof(struct user_regs_struct,fs_base): if (value >= TASK_SIZE_OF(child))
next prev parent reply other threads:[~2008-03-07 22:57 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-02-29 3:57 [PATCH] x86_64 ia32 syscall restart fix Roland McGrath 2008-02-29 15:52 ` Ingo Molnar 2008-02-29 16:26 ` Linus Torvalds 2008-02-29 16:45 ` Ingo Molnar 2008-02-29 17:03 ` Linus Torvalds 2008-02-29 17:17 ` Ingo Molnar 2008-02-29 17:37 ` Ingo Molnar 2008-02-29 21:02 ` Andrew Morton 2008-02-29 21:20 ` Ingo Molnar 2008-03-01 5:48 ` [stable] " Greg KH 2008-02-29 22:42 ` Roland McGrath 2008-02-29 23:18 ` Linus Torvalds 2008-03-07 22:56 ` Roland McGrath [this message] 2008-03-07 23:18 ` [PATCH] x86_64 ptrace orig_ax on ia32 task Linus Torvalds 2008-03-08 1:37 ` Roland McGrath 2008-03-10 19:19 ` Chuck Ebbert 2008-03-10 19:48 ` Linus Torvalds 2008-03-10 20:01 ` Roland McGrath 2008-03-11 9:32 ` Ingo Molnar
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=20080307225602.6491B26F990@magilla.localdomain \ --to=roland@redhat.com \ --cc=akpm@linux-foundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@elte.hu \ --cc=tglx@linutronix.de \ --cc=torvalds@linux-foundation.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: linkBe 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; as well as URLs for NNTP newsgroup(s).