kprobes, x86/ptrace.h: fix regs argument order for i386
Subsystems (3)
PATCH 1/1 kprobes, x86/ptrace.h: fix regs argument order for i386
On i386, the order of parameters passed on regs is eax,edx,and ecx (as per regparm(3) calling conventions).
Change the mapping in regs_get_kernel_argument(), so that arg1=ax arg2=dx, and arg3=cx.
Running the selftests testcase kprobes_args_use.tc shows the result as passed.
--- arch/x86/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +1 -1
@@ -327,8 +327,8 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,static const unsigned int argument_offs[] = { #ifdef __i386__ offsetof(struct pt_regs , ax), - offsetof(struct pt_regs , cx), offsetof(struct pt_regs , dx), + offsetof(struct pt_regs , cx), #define NR_REG_ARGUMENTS 3 #else offsetof(struct pt_regs, di),
Signature · 1 line
2.7.4
Quoted 8 lines · On Fri, 28 Aug 2020 17:02:46 +0530 Vamshi K Sthambamkadi…
On i386, the order of parameters passed on regs is eax,edx,and ecx (as per regparm(3) calling conventions).
Change the mapping in
regs_get_kernel_argument(), so that arg1=ax arg2=dx, and arg3=cx.Running the selftests testcase kprobes_args_use.tc shows the result as passed.
Good catch! BTW, this is for tracing (ftrace kprobe events), so the "tracing/kprobes:" tag is better. Anyway,
Thank you,
Quoted 23 lines
Signed-off-by Vamshi K Sthambamkadi <[email protected]>--- arch/x86/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/ptrace.h +1
-1@@ -327,8 +327,8 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,static const unsigned int argument_offs[] = { #ifdef __i386__ offsetof(struct pt_regs , ax), - offsetof(struct pt_regs , cx), offsetof(struct pt_regs , dx), + offsetof(struct pt_regs , cx), #define NR_REG_ARGUMENTS 3 #else offsetof(struct pt_regs, di),Signature · 1 line
2.7.4
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 9 lines · Vamshi K Sthambamkadi
On i386, the order of parameters passed on regs is eax,edx,and ecx (as per regparm(3) calling conventions).
Change the mapping in
regs_get_kernel_argument(), so that arg1=ax arg2=dx, and arg3=cx.Running the selftests testcase kprobes_args_use.tc shows the result as passed.
Quoted 1 line
Signed-off-by Vamshi K Sthambamkadi <[email protected]>
Quoted 21 lines
--- arch/x86/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/ptrace.h +1
-1@@ -327,8 +327,8 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,static const unsigned int argument_offs[] = { #ifdef __i386__ offsetof(struct pt_regs , ax), - offsetof(struct pt_regs , cx), offsetof(struct pt_regs , dx), + offsetof(struct pt_regs , cx), #define NR_REG_ARGUMENTS 3 #else offsetof(struct pt_regs, di),Signature · 1 line
2.7.4
[tip: x86/urgent] tracing/kprobes, x86/ptrace: Fix regs argument order for i386
In reply to Vamshi K SthambamkadiThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 2356bb4b8221d7dc8c7beb810418122ed90254c9 Gitweb: https://git.kernel.org/tip/2356bb4b8221d7dc8c7beb810418122ed90254c9 Author: Vamshi K Sthambamkadi <[email protected]> AuthorDate: Fri, 28 Aug 2020 17:02:46 +05:30 Committer: Borislav Petkov <[email protected]> CommitterDate: Fri, 04 Sep 2020 14:40:42 +02:00
tracing/kprobes, x86/ptrace: Fix regs argument order for i386
On i386, the order of parameters passed on regs is eax,edx,and ecx (as per regparm(3) calling conventions).
Change the mapping in regs_get_kernel_argument(), so that arg1=ax arg2=dx, and arg3=cx.
Running the selftests testcase kprobes_args_use.tc shows the result as passed.
--- arch/x86/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +1 -1
@@ -327,8 +327,8 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,static const unsigned int argument_offs[] = { #ifdef __i386__ offsetof(struct pt_regs , ax), - offsetof(struct pt_regs , cx), offsetof(struct pt_regs , dx), + offsetof(struct pt_regs , cx), #define NR_REG_ARGUMENTS 3 #else offsetof(struct pt_regs, di),