From: Dmitry V. Levin Date: Mon, 31 Jul 2017 18:21:56 +0000 (+0000) Subject: ucopy: move process_vm_readv ENOSYS check to vm_read_mem X-Git-Tag: v4.19~193 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5edeed429591c383b8f334bb157ff5c673e1b772;p=strace ucopy: move process_vm_readv ENOSYS check to vm_read_mem * ucopy.c (vm_read_mem): Set process_vm_readv_not_supported in case of ENOSYS. * ucopy.c (umoven, umovestr): Do not set process_vm_readv_not_supported. --- diff --git a/ucopy.c b/ucopy.c index 9796756e..f1e2b4aa 100644 --- a/ucopy.c +++ b/ucopy.c @@ -83,7 +83,11 @@ vm_read_mem(const pid_t pid, void *const laddr, .iov_len = len }; - return process_vm_readv(pid, &local, 1, &remote, 1, 0); + const ssize_t rc = process_vm_readv(pid, &local, 1, &remote, 1, 0); + if (rc < 0 && errno == ENOSYS) + process_vm_readv_not_supported = true; + + return rc; } static bool @@ -127,11 +131,8 @@ umoven(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len, } switch (errno) { case ENOSYS: - /* never try it again */ - process_vm_readv_not_supported = 1; - break; case EPERM: - /* operation not permitted, try PTRACE_PEEKDATA */ + /* try PTRACE_PEEKDATA */ break; case ESRCH: /* the process is gone */ @@ -268,14 +269,8 @@ umovestr(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len, char *lad } switch (errno) { case ENOSYS: - /* never try it again */ - process_vm_readv_not_supported = 1; - goto vm_readv_didnt_work; - case ESRCH: - /* the process is gone */ - return -1; case EPERM: - /* operation not permitted, try PTRACE_PEEKDATA */ + /* try PTRACE_PEEKDATA */ if (!nread) goto vm_readv_didnt_work; /* fall through */ @@ -286,6 +281,9 @@ umovestr(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len, char *lad nread, nread + len, addr - nread); } return -1; + case ESRCH: + /* the process is gone */ + return -1; default: /* all the rest is strange and should be reported */ perror_msg("process_vm_readv: pid:%d @0x%" PRI_klx,