static long *fetch_remote_addrs(void) { long *foo, *bar; char buf[BUFSIZ]; long len; struct iovec local, remote; /* get addr from pipe */ SAFE_CLOSE(tst_exit, pipe_fd[1]); SAFE_READ(tst_exit, 0, pipe_fd[0], buf, BUFSIZ); SAFE_CLOSE(tst_exit, pipe_fd[0]); if (sscanf(buf, "%p", &foo) != 1) tst_brkm(TBROK | TERRNO, tst_exit, "sscanf"); len = nr_iovecs * sizeof(long); bar = SAFE_MALLOC(tst_exit, len); local.iov_base = bar; local.iov_len = len; remote.iov_base = foo; remote.iov_len = len; TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0)); if (TEST_RETURN != len) tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv"); return local.iov_base; }
static void cma_test_params_read(struct process_vm_params *params) { TEST(test_process_vm_readv(params->pid, params->lvec, params->liovcnt, params->rvec, params->riovcnt, params->flags)); }
static void child_invoke(void) { char *lp, *rp; char buf[BUFSIZ]; struct iovec local, remote; /* get addr from pipe */ SAFE_CLOSE(tst_exit, pipe_fd[1]); SAFE_READ(tst_exit, 0, pipe_fd[0], buf, BUFSIZ); SAFE_CLOSE(tst_exit, pipe_fd[0]); if (sscanf(buf, "%p", &rp) != 1) tst_brkm(TBROK | TERRNO, tst_exit, "sscanf"); lp = SAFE_MALLOC(tst_exit, len + 1); local.iov_base = lp; local.iov_len = len; remote.iov_base = rp; remote.iov_len = len; tst_resm(TINFO, "child 1: reading string from same memory location."); TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0)); if (TEST_RETURN != len) tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv"); if (strncmp(lp, tst_string, len) != 0) tst_brkm(TFAIL, tst_exit, "child 1: expected string: %s, " "received string: %256s", tst_string, lp); else tst_resm(TPASS, "expected string received."); }
int main(void) { if (!test_process_vm_readv()) perror_msg_and_skip("process_vm_readv"); test_printstrn(4096); puts("+++ exited with 0 +++"); return 0; }
int main(void) { if (!test_process_vm_readv()) perror_msg_and_skip("process_vm_readv"); test_printpath(PATH_MAX); puts("+++ exited with 0 +++"); return 0; }
static void child_invoke(int *bufsz_arr) { int i, j, count, nr_error; unsigned char expect, actual; long *addrs; struct iovec local[NUM_LOCAL_VECS], *remote; int rcv_arr[NUM_LOCAL_VECS]; addrs = fetch_remote_addrs(); remote = SAFE_MALLOC(tst_exit, nr_iovecs * sizeof(struct iovec)); for (i = 0; i < nr_iovecs; i++) { remote[i].iov_base = (void *)addrs[i]; remote[i].iov_len = bufsz_arr[i]; } tst_resm(TINFO, "child 1: %d remote iovecs received.", nr_iovecs); gen_random_arr(rcv_arr, NUM_LOCAL_VECS); for (i = 0; i < NUM_LOCAL_VECS; i++) { local[i].iov_base = SAFE_MALLOC(tst_exit, rcv_arr[i]); local[i].iov_len = rcv_arr[i]; } tst_resm(TINFO, "child 1: %d local iovecs initialized.", NUM_LOCAL_VECS); TEST(test_process_vm_readv(pids[0], local, NUM_LOCAL_VECS, remote, nr_iovecs, 0)); if (TEST_RETURN != bufsz) tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv"); /* verify every byte */ count = 0; nr_error = 0; for (i = 0; i < NUM_LOCAL_VECS; i++) { for (j = 0; j < local[i].iov_len; j++) { expect = count % 256; actual = ((unsigned char *)local[i].iov_base)[j]; if (expect != actual) { #if DEBUG tst_resm(TFAIL, "child 1: expected %i, got %i " "for byte seq %d", expect, actual, count); #endif nr_error++; } count++; } } if (nr_error) tst_brkm(TFAIL, tst_exit, "child 1: %d incorrect bytes " "received.", nr_error); else tst_resm(TPASS, "child 1: all bytes are correctly received."); }
int main(int ac, char **av) { if (ac < 2 && test_process_vm_readv()) error_msg_and_skip("process_vm_readv is available"); if (!test_ptrace_peekdata()) perror_msg_and_skip("PTRACE_PEEKDATA"); test_printpath(sizeof(long) * 4); puts("+++ exited with 0 +++"); return 0; }
int main(void) { if (!test_process_vm_readv()) perror_msg_and_skip("process_vm_readv"); /* * Clearing dumpable flag disallows process_vm_readv. * If the kernel does not contain commit * 84d77d3f06e7e8dea057d10e8ec77ad71f721be3, then * PTRACE_PEEKDATA remains allowed. */ if (prctl(PR_SET_DUMPABLE, 0)) perror_msg_and_skip("PR_SET_DUMPABLE 0"); if (!test_ptrace_peekdata()) perror_msg_and_skip("PTRACE_PEEKDATA"); test_printpath(sizeof(long) * 4); puts("+++ exited with 0 +++"); return 0; }