]> granicus.if.org Git - strace/commitdiff
ucopy: move process_vm_readv ENOSYS check to vm_read_mem
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 31 Jul 2017 18:21:56 +0000 (18:21 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 31 Jul 2017 18:21:56 +0000 (18:21 +0000)
* 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.

ucopy.c

diff --git a/ucopy.c b/ucopy.c
index 9796756e53b74e623051c49ea8953ecdbb4de356..f1e2b4aadfcc43f3a4d14f07e597f5d541877faf 100644 (file)
--- 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,