From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908AbZDVXNK (ORCPT ); Wed, 22 Apr 2009 19:13:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751794AbZDVXMy (ORCPT ); Wed, 22 Apr 2009 19:12:54 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57357 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbZDVXMx (ORCPT ); Wed, 22 Apr 2009 19:12:53 -0400 Message-ID: <49EFA4DA.9020402@redhat.com> Date: Wed, 22 Apr 2009 19:14:34 -0400 From: Masami Hiramatsu User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: "Luck, Tony" , Anil S Keshavamurthy CC: LKML , ia64 , Roland McGrath , David Smith , systemtap-ml Subject: [PATCH][BUGFIX] utrace/ia64: Fix syscall_get_set_args_cb() to handle syscalls via syscall() X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix syscall_get_set_args_cb() to decode user-stack correctly in case of syscall() which allocates locals in user-stack. If locals (cfm.sol) exist on the stack, we have to skip it for getting real systemcall arguments. And also, fix the number of getting arguments which must be less than (nr outputs - args->i) instead of nr outputs, because args->i is the indent number (this means, syscall_get_set_args_cb() get/set arguments from (i)th to (i+n)th.) Signed-off-by: Masami Hiramatsu Cc: Anil S Keshavamurthy Cc: Roland McGrath Cc: David Smith --- arch/ia64/kernel/ptrace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) Index: 2.6-rc/arch/ia64/kernel/ptrace.c =================================================================== --- 2.6-rc.orig/arch/ia64/kernel/ptrace.c +++ 2.6-rc/arch/ia64/kernel/ptrace.c @@ -2189,6 +2189,10 @@ struct syscall_get_set_args { int rw; }; +#define CFM_SOF(cfm) ((cfm) & 0x7f) /* Size of frame */ +#define CFM_SOL(cfm) (((cfm) >> 7) & 0x7f) /* Size of locals */ +#define CFM_OUT(cfm) (CFM_SOF(cfm) - CFM_SOL(cfm)) /* Size of outputs */ + static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data) { struct syscall_get_set_args *args = data; @@ -2205,15 +2209,18 @@ static void syscall_get_set_args_cb(stru count = 0; if (in_syscall(pt)) - count = min_t(int, args->n, cfm & 0x7f); + /* args->i + args->n must be less equal than nr outputs */ + count = min_t(int, args->n, CFM_OUT(cfm) - args->i); for (i = 0; i < count; i++) { + /* Skips dirties and locals */ if (args->rw) - *ia64_rse_skip_regs(krbs, ndirty + i + args->i) = + *ia64_rse_skip_regs(krbs, + ndirty + CFM_SOL(cfm) + args->i + i) = args->args[i]; else args->args[i] = *ia64_rse_skip_regs(krbs, - ndirty + i + args->i); + ndirty + CFM_SOL(cfm) + args->i + i); } if (!args->rw) { -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: mhiramat@redhat.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masami Hiramatsu Date: Wed, 22 Apr 2009 23:14:34 +0000 Subject: [PATCH][BUGFIX] utrace/ia64: Fix syscall_get_set_args_cb() to handle Message-Id: <49EFA4DA.9020402@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Luck, Tony" , Anil S Keshavamurthy Cc: LKML , ia64 , Roland McGrath , David Smith , systemtap-ml Fix syscall_get_set_args_cb() to decode user-stack correctly in case of syscall() which allocates locals in user-stack. If locals (cfm.sol) exist on the stack, we have to skip it for getting real systemcall arguments. And also, fix the number of getting arguments which must be less than (nr outputs - args->i) instead of nr outputs, because args->i is the indent number (this means, syscall_get_set_args_cb() get/set arguments from (i)th to (i+n)th.) Signed-off-by: Masami Hiramatsu Cc: Anil S Keshavamurthy Cc: Roland McGrath Cc: David Smith --- arch/ia64/kernel/ptrace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) Index: 2.6-rc/arch/ia64/kernel/ptrace.c =================================--- 2.6-rc.orig/arch/ia64/kernel/ptrace.c +++ 2.6-rc/arch/ia64/kernel/ptrace.c @@ -2189,6 +2189,10 @@ struct syscall_get_set_args { int rw; }; +#define CFM_SOF(cfm) ((cfm) & 0x7f) /* Size of frame */ +#define CFM_SOL(cfm) (((cfm) >> 7) & 0x7f) /* Size of locals */ +#define CFM_OUT(cfm) (CFM_SOF(cfm) - CFM_SOL(cfm)) /* Size of outputs */ + static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data) { struct syscall_get_set_args *args = data; @@ -2205,15 +2209,18 @@ static void syscall_get_set_args_cb(stru count = 0; if (in_syscall(pt)) - count = min_t(int, args->n, cfm & 0x7f); + /* args->i + args->n must be less equal than nr outputs */ + count = min_t(int, args->n, CFM_OUT(cfm) - args->i); for (i = 0; i < count; i++) { + /* Skips dirties and locals */ if (args->rw) - *ia64_rse_skip_regs(krbs, ndirty + i + args->i) + *ia64_rse_skip_regs(krbs, + ndirty + CFM_SOL(cfm) + args->i + i) args->args[i]; else args->args[i] = *ia64_rse_skip_regs(krbs, - ndirty + i + args->i); + ndirty + CFM_SOL(cfm) + args->i + i); } if (!args->rw) { -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: mhiramat@redhat.com