From 25f91fd854b5602249d5c52e84846c769b130f9c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 18 Aug 2017 14:30:08 +0000 Subject: [PATCH] mips o32: do not bail out in get_syscall_args if umoven fails If the kernel contains commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3, both PTRACE_PEEKDATA and process_vm_readv become unavailable when the process dumpable flag is cleared. As the first 4 syscall arguments are still available via registers, do not treat this as get_syscall_args error. This condition is triggered and therefore tested by prctl-dumpable test. * linux/mips/get_syscall_args.c (get_syscall_args) [LINUX_MIPSO32]: Do not bail out if umoven fails. --- linux/mips/get_syscall_args.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/linux/mips/get_syscall_args.c b/linux/mips/get_syscall_args.c index ca2819bf..3c9160e3 100644 --- a/linux/mips/get_syscall_args.c +++ b/linux/mips/get_syscall_args.c @@ -14,11 +14,16 @@ get_syscall_args(struct tcb *tcp) tcp->u_arg[1] = mips_REG_A1; tcp->u_arg[2] = mips_REG_A2; tcp->u_arg[3] = mips_REG_A3; - if (tcp->s_ent->nargs > 4) { - if (umoven(tcp, mips_REG_SP + 4 * 4, - (tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]), - &tcp->u_arg[4]) < 0) - return -1; + if (tcp->s_ent->nargs > 4 + && umoven(tcp, mips_REG_SP + 4 * sizeof(tcp->u_arg[0]), + (tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]), + &tcp->u_arg[4]) < 0) { + /* + * Let's proceed with the first 4 arguments + * instead of reporting the failure. + */ + memset(&tcp->u_arg[4], 0, + (tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0])); } #else # error unsupported mips abi -- 2.40.0