1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <sys/ptrace.h>
18
19 #include <elf.h>
20 #include <err.h>
21 #include <fcntl.h>
22 #include <sched.h>
23 #include <sys/prctl.h>
24 #include <sys/ptrace.h>
25 #include <sys/uio.h>
26 #include <sys/user.h>
27 #include <sys/wait.h>
28 #include <unistd.h>
29
30 #include <chrono>
31 #include <thread>
32
33 #include <gtest/gtest.h>
34
35 #include <android-base/macros.h>
36 #include <android-base/unique_fd.h>
37
38 #include "utils.h"
39
40 using namespace std::chrono_literals;
41
42 using android::base::unique_fd;
43
44 class ChildGuard {
45 public:
ChildGuard(pid_t pid)46 explicit ChildGuard(pid_t pid) : pid(pid) {}
47
~ChildGuard()48 ~ChildGuard() {
49 kill(pid, SIGKILL);
50 int status;
51 TEMP_FAILURE_RETRY(waitpid(pid, &status, 0));
52 }
53
54 private:
55 pid_t pid;
56 };
57
58 enum class HwFeature { Watchpoint, Breakpoint };
59
check_hw_feature_supported(pid_t child,HwFeature feature)60 static void check_hw_feature_supported(pid_t child, HwFeature feature) {
61 #if defined(__arm__)
62 errno = 0;
63 long capabilities;
64 long result = ptrace(PTRACE_GETHBPREGS, child, 0, &capabilities);
65 if (result == -1) {
66 EXPECT_ERRNO(EIO);
67 GTEST_SKIP() << "Hardware debug support disabled at kernel configuration time";
68 }
69 uint8_t hb_count = capabilities & 0xff;
70 capabilities >>= 8;
71 uint8_t wp_count = capabilities & 0xff;
72 capabilities >>= 8;
73 uint8_t max_wp_size = capabilities & 0xff;
74 if (max_wp_size == 0) {
75 GTEST_SKIP() << "Kernel reports zero maximum watchpoint size";
76 } else if (feature == HwFeature::Watchpoint && wp_count == 0) {
77 GTEST_SKIP() << "Kernel reports zero hardware watchpoints";
78 } else if (feature == HwFeature::Breakpoint && hb_count == 0) {
79 GTEST_SKIP() << "Kernel reports zero hardware breakpoints";
80 }
81 #elif defined(__aarch64__)
82 user_hwdebug_state dreg_state;
83 iovec iov;
84 iov.iov_base = &dreg_state;
85 iov.iov_len = sizeof(dreg_state);
86
87 errno = 0;
88 long result = ptrace(PTRACE_GETREGSET, child,
89 feature == HwFeature::Watchpoint ? NT_ARM_HW_WATCH : NT_ARM_HW_BREAK, &iov);
90 if (result == -1) {
91 ASSERT_ERRNO(EINVAL);
92 GTEST_SKIP() << "Hardware support missing";
93 } else if ((dreg_state.dbg_info & 0xff) == 0) {
94 if (feature == HwFeature::Watchpoint) {
95 GTEST_SKIP() << "Kernel reports zero hardware watchpoints";
96 } else {
97 GTEST_SKIP() << "Kernel reports zero hardware breakpoints";
98 }
99 }
100 #else
101 // We assume watchpoints and breakpoints are always supported on x86.
102 UNUSED(child);
103 UNUSED(feature);
104 #endif
105 }
106
set_watchpoint(pid_t child,uintptr_t address,size_t size)107 static void set_watchpoint(pid_t child, uintptr_t address, size_t size) {
108 ASSERT_EQ(0u, address & 0x7) << "address: " << address;
109 #if defined(__arm__) || defined(__aarch64__)
110 const unsigned byte_mask = (1 << size) - 1;
111 const unsigned type = 2; // Write.
112 const unsigned enable = 1;
113 const unsigned control = byte_mask << 5 | type << 3 | enable;
114
115 #ifdef __arm__
116 ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, -1, &address)) << strerror(errno);
117 ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, -2, &control)) << strerror(errno);
118 #else // aarch64
119 user_hwdebug_state dreg_state = {};
120 dreg_state.dbg_regs[0].addr = address;
121 dreg_state.dbg_regs[0].ctrl = control;
122
123 iovec iov;
124 iov.iov_base = &dreg_state;
125 iov.iov_len = offsetof(user_hwdebug_state, dbg_regs) + sizeof(dreg_state.dbg_regs[0]);
126
127 ASSERT_EQ(0, ptrace(PTRACE_SETREGSET, child, NT_ARM_HW_WATCH, &iov)) << strerror(errno);
128 #endif
129 #elif defined(__i386__) || defined(__x86_64__)
130 ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[0]), address)) << strerror(errno);
131 errno = 0;
132 unsigned data = ptrace(PTRACE_PEEKUSER, child, offsetof(user, u_debugreg[7]), nullptr);
133 ASSERT_ERRNO(0);
134
135 const unsigned size_flag = (size == 8) ? 2 : size - 1;
136 const unsigned enable = 1;
137 const unsigned type = 1; // Write.
138
139 const unsigned mask = 3 << 18 | 3 << 16 | 1;
140 const unsigned value = size_flag << 18 | type << 16 | enable;
141 data &= mask;
142 data |= value;
143 ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[7]), data)) << strerror(errno);
144 #else
145 UNUSED(child);
146 UNUSED(address);
147 UNUSED(size);
148 #endif
149 }
150
151 template <typename T>
run_watchpoint_test(std::function<void (T &)> child_func,size_t offset,size_t size)152 static void run_watchpoint_test(std::function<void(T&)> child_func, size_t offset, size_t size) {
153 alignas(16) T data{};
154
155 pid_t child = fork();
156 ASSERT_NE(-1, child) << strerror(errno);
157 if (child == 0) {
158 // Extra precaution: make sure we go away if anything happens to our parent.
159 if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) {
160 perror("prctl(PR_SET_PDEATHSIG)");
161 _exit(1);
162 }
163
164 if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1) {
165 perror("ptrace(PTRACE_TRACEME)");
166 _exit(2);
167 }
168
169 child_func(data);
170 _exit(0);
171 }
172
173 ChildGuard guard(child);
174
175 int status;
176 ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno);
177 ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
178 ASSERT_EQ(SIGSTOP, WSTOPSIG(status)) << "Status was: " << status;
179
180 check_hw_feature_supported(child, HwFeature::Watchpoint);
181 if (::testing::Test::IsSkipped()) {
182 return;
183 }
184
185 set_watchpoint(child, uintptr_t(untag_address(&data)) + offset, size);
186
187 ASSERT_EQ(0, ptrace(PTRACE_CONT, child, nullptr, nullptr)) << strerror(errno);
188 ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno);
189 ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
190 ASSERT_EQ(SIGTRAP, WSTOPSIG(status)) << "Status was: " << status;
191
192 siginfo_t siginfo;
193 ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child, nullptr, &siginfo)) << strerror(errno);
194 ASSERT_EQ(TRAP_HWBKPT, siginfo.si_code);
195 #if defined(__arm__) || defined(__aarch64__)
196 ASSERT_LE(&data, siginfo.si_addr);
197 ASSERT_GT((&data) + 1, siginfo.si_addr);
198 #endif
199 }
200
201 template <typename T>
watchpoint_stress_child(unsigned cpu,T & data)202 static void watchpoint_stress_child(unsigned cpu, T& data) {
203 cpu_set_t cpus;
204 CPU_ZERO(&cpus);
205 CPU_SET(cpu, &cpus);
206 if (sched_setaffinity(0, sizeof cpus, &cpus) == -1) {
207 perror("sched_setaffinity");
208 _exit(3);
209 }
210 raise(SIGSTOP); // Synchronize with the tracer, let it set the watchpoint.
211
212 data = 1; // Now trigger the watchpoint.
213 }
214
215 template <typename T>
run_watchpoint_stress(size_t cpu)216 static void run_watchpoint_stress(size_t cpu) {
217 run_watchpoint_test<T>(std::bind(watchpoint_stress_child<T>, cpu, std::placeholders::_1), 0,
218 sizeof(T));
219 }
220
221 // Test watchpoint API. The test is considered successful if our watchpoints get hit OR the
222 // system reports that watchpoint support is not present. We run the test for different
223 // watchpoint sizes, while pinning the process to each cpu in turn, for better coverage.
TEST(sys_ptrace,watchpoint_stress)224 TEST(sys_ptrace, watchpoint_stress) {
225 cpu_set_t available_cpus;
226 ASSERT_EQ(0, sched_getaffinity(0, sizeof available_cpus, &available_cpus));
227
228 for (size_t cpu = 0; cpu < CPU_SETSIZE; ++cpu) {
229 if (!CPU_ISSET(cpu, &available_cpus)) continue;
230
231 run_watchpoint_stress<uint8_t>(cpu);
232 if (::testing::Test::IsSkipped()) {
233 // Only check first case, since all others would skip for same reason.
234 return;
235 }
236 run_watchpoint_stress<uint16_t>(cpu);
237 run_watchpoint_stress<uint32_t>(cpu);
238 #if defined(__LP64__)
239 run_watchpoint_stress<uint64_t>(cpu);
240 #endif
241 }
242 }
243
244 struct Uint128_t {
245 uint64_t data[2];
246 };
watchpoint_imprecise_child(Uint128_t & data)247 static void watchpoint_imprecise_child(Uint128_t& data) {
248 raise(SIGSTOP); // Synchronize with the tracer, let it set the watchpoint.
249
250 #if defined(__i386__) || defined(__x86_64__)
251 asm volatile("movdqa %%xmm0, %0" : : "m"(data));
252 #elif defined(__arm__)
253 asm volatile("stm %0, { r0, r1, r2, r3 }" : : "r"(&data));
254 #elif defined(__aarch64__)
255 asm volatile("stp x0, x1, %0" : : "m"(data));
256 #elif defined(__riscv)
257 UNUSED(data);
258 GTEST_LOG_(INFO) << "missing riscv64 instruction to store > 64 bits in one instruction";
259 #endif
260 }
261
262 // Test that the kernel is able to handle the case when the instruction writes
263 // to a larger block of memory than the one we are watching. If you see this
264 // test fail on arm64, you will likely need to cherry-pick fdfeff0f into your
265 // kernel.
TEST(sys_ptrace,watchpoint_imprecise)266 TEST(sys_ptrace, watchpoint_imprecise) {
267 // This test relies on the infrastructure to timeout if the test hangs.
268 run_watchpoint_test<Uint128_t>(watchpoint_imprecise_child, 8, sizeof(void*));
269 }
270
breakpoint_func()271 static void __attribute__((noinline)) breakpoint_func() {
272 asm volatile("");
273 }
274
breakpoint_fork_child()275 static void __attribute__((noreturn)) breakpoint_fork_child() {
276 // Extra precaution: make sure we go away if anything happens to our parent.
277 if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) {
278 perror("prctl(PR_SET_PDEATHSIG)");
279 _exit(1);
280 }
281
282 if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1) {
283 perror("ptrace(PTRACE_TRACEME)");
284 _exit(2);
285 }
286
287 raise(SIGSTOP); // Synchronize with the tracer, let it set the breakpoint.
288
289 breakpoint_func(); // Now trigger the breakpoint.
290
291 _exit(0);
292 }
293
set_breakpoint(pid_t child)294 static void set_breakpoint(pid_t child) {
295 uintptr_t address = uintptr_t(breakpoint_func);
296 #if defined(__arm__) || defined(__aarch64__)
297 address &= ~3;
298 const unsigned byte_mask = 0xf;
299 const unsigned enable = 1;
300 const unsigned control = byte_mask << 5 | enable;
301
302 #ifdef __arm__
303 ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, 1, &address)) << strerror(errno);
304 ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, 2, &control)) << strerror(errno);
305 #else // aarch64
306 user_hwdebug_state dreg_state = {};
307 dreg_state.dbg_regs[0].addr = reinterpret_cast<uintptr_t>(address);
308 dreg_state.dbg_regs[0].ctrl = control;
309
310 iovec iov;
311 iov.iov_base = &dreg_state;
312 iov.iov_len = offsetof(user_hwdebug_state, dbg_regs) + sizeof(dreg_state.dbg_regs[0]);
313
314 ASSERT_EQ(0, ptrace(PTRACE_SETREGSET, child, NT_ARM_HW_BREAK, &iov)) << strerror(errno);
315 #endif
316 #elif defined(__i386__) || defined(__x86_64__)
317 ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[0]), address))
318 << strerror(errno);
319 errno = 0;
320 unsigned data = ptrace(PTRACE_PEEKUSER, child, offsetof(user, u_debugreg[7]), nullptr);
321 ASSERT_ERRNO(0);
322
323 const unsigned size = 0;
324 const unsigned enable = 1;
325 const unsigned type = 0; // Execute
326
327 const unsigned mask = 3 << 18 | 3 << 16 | 1;
328 const unsigned value = size << 18 | type << 16 | enable;
329 data &= mask;
330 data |= value;
331 ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[7]), data))
332 << strerror(errno);
333 #else
334 UNUSED(child);
335 UNUSED(address);
336 #endif
337 }
338
339 // Test hardware breakpoint API. The test is considered successful if the breakpoints get hit OR the
340 // system reports that hardware breakpoint support is not present.
TEST(sys_ptrace,hardware_breakpoint)341 TEST(sys_ptrace, hardware_breakpoint) {
342 pid_t child = fork();
343 ASSERT_NE(-1, child) << strerror(errno);
344 if (child == 0) breakpoint_fork_child();
345
346 ChildGuard guard(child);
347
348 int status;
349 ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno);
350 ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
351 ASSERT_EQ(SIGSTOP, WSTOPSIG(status)) << "Status was: " << status;
352
353 check_hw_feature_supported(child, HwFeature::Breakpoint);
354 if (::testing::Test::IsSkipped()) {
355 return;
356 }
357
358 set_breakpoint(child);
359
360 ASSERT_EQ(0, ptrace(PTRACE_CONT, child, nullptr, nullptr)) << strerror(errno);
361 ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno);
362 ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
363 ASSERT_EQ(SIGTRAP, WSTOPSIG(status)) << "Status was: " << status;
364
365 siginfo_t siginfo;
366 ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child, nullptr, &siginfo)) << strerror(errno);
367 ASSERT_EQ(TRAP_HWBKPT, siginfo.si_code);
368 }
369
370 class PtraceResumptionTest : public ::testing::Test {
371 public:
372 unique_fd worker_pipe_write;
373
374 pid_t worker = -1;
375 pid_t tracer = -1;
376
PtraceResumptionTest()377 PtraceResumptionTest() {
378 unique_fd worker_pipe_read;
379 if (!android::base::Pipe(&worker_pipe_read, &worker_pipe_write)) {
380 err(1, "failed to create pipe");
381 }
382
383 // Second pipe to synchronize the Yama ptracer setup.
384 unique_fd worker_pipe_setup_read, worker_pipe_setup_write;
385 if (!android::base::Pipe(&worker_pipe_setup_read, &worker_pipe_setup_write)) {
386 err(1, "failed to create pipe");
387 }
388
389 worker = fork();
390 if (worker == -1) {
391 err(1, "failed to fork worker");
392 } else if (worker == 0) {
393 char buf;
394 // Allow the tracer process, which is not a direct process ancestor, to
395 // be able to use ptrace(2) on this process when Yama LSM is active.
396 if (prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0) == -1) {
397 // if Yama is off prctl(PR_SET_PTRACER) returns EINVAL - don't log in this
398 // case since it's expected behaviour.
399 if (errno != EINVAL) {
400 err(1, "prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY) failed for pid %d", getpid());
401 }
402 }
403 worker_pipe_setup_write.reset();
404
405 worker_pipe_write.reset();
406 TEMP_FAILURE_RETRY(read(worker_pipe_read.get(), &buf, sizeof(buf)));
407 exit(0);
408 } else {
409 // Wait until the Yama ptracer is setup.
410 char buf;
411 worker_pipe_setup_write.reset();
412 TEMP_FAILURE_RETRY(read(worker_pipe_setup_read.get(), &buf, sizeof(buf)));
413 }
414 }
415
~PtraceResumptionTest()416 ~PtraceResumptionTest() override {
417 }
418
419 void AssertDeath(int signo);
420
StartTracer(std::function<void ()> f)421 void StartTracer(std::function<void()> f) {
422 tracer = fork();
423 ASSERT_NE(-1, tracer);
424 if (tracer == 0) {
425 f();
426 if (HasFatalFailure()) {
427 exit(1);
428 }
429 exit(0);
430 }
431 }
432
WaitForTracer()433 bool WaitForTracer() {
434 if (tracer == -1) {
435 errx(1, "tracer not started");
436 }
437
438 int result;
439 pid_t rc = TEMP_FAILURE_RETRY(waitpid(tracer, &result, 0));
440 if (rc != tracer) {
441 printf("waitpid returned %d (%s)\n", rc, strerror(errno));
442 return false;
443 }
444
445 if (!WIFEXITED(result) && !WIFSIGNALED(result)) {
446 printf("!WIFEXITED && !WIFSIGNALED\n");
447 return false;
448 }
449
450 if (WIFEXITED(result)) {
451 if (WEXITSTATUS(result) != 0) {
452 printf("tracer failed\n");
453 return false;
454 }
455 }
456
457 return true;
458 }
459
WaitForWorker()460 bool WaitForWorker() {
461 if (worker == -1) {
462 errx(1, "worker not started");
463 }
464
465 int result;
466 pid_t rc = TEMP_FAILURE_RETRY(waitpid(worker, &result, WNOHANG));
467 if (rc != 0) {
468 printf("worker exited prematurely\n");
469 return false;
470 }
471
472 worker_pipe_write.reset();
473
474 rc = TEMP_FAILURE_RETRY(waitpid(worker, &result, 0));
475 if (rc != worker) {
476 printf("waitpid for worker returned %d (%s)\n", rc, strerror(errno));
477 return false;
478 }
479
480 if (!WIFEXITED(result)) {
481 printf("worker didn't exit\n");
482 return false;
483 }
484
485 if (WEXITSTATUS(result) != 0) {
486 printf("worker exited with status %d\n", WEXITSTATUS(result));
487 return false;
488 }
489
490 return true;
491 }
492 };
493
wait_for_ptrace_stop(pid_t pid)494 static void wait_for_ptrace_stop(pid_t pid) {
495 while (true) {
496 int status;
497 pid_t rc = TEMP_FAILURE_RETRY(waitpid(pid, &status, __WALL));
498 if (rc != pid) {
499 abort();
500 }
501 if (WIFSTOPPED(status)) {
502 return;
503 }
504 }
505 }
506
TEST_F(PtraceResumptionTest,smoke)507 TEST_F(PtraceResumptionTest, smoke) {
508 // Make sure that the worker doesn't exit before the tracer stops tracing.
509 StartTracer([this]() {
510 ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno);
511 ASSERT_EQ(0, ptrace(PTRACE_INTERRUPT, worker, 0, 0)) << strerror(errno);
512 wait_for_ptrace_stop(worker);
513 std::this_thread::sleep_for(500ms);
514 });
515
516 worker_pipe_write.reset();
517 std::this_thread::sleep_for(250ms);
518
519 int result;
520 ASSERT_EQ(0, TEMP_FAILURE_RETRY(waitpid(worker, &result, WNOHANG)));
521 ASSERT_TRUE(WaitForTracer());
522 ASSERT_EQ(worker, TEMP_FAILURE_RETRY(waitpid(worker, &result, 0)));
523 }
524
TEST_F(PtraceResumptionTest,seize)525 TEST_F(PtraceResumptionTest, seize) {
526 StartTracer([this]() { ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno); });
527 ASSERT_TRUE(WaitForTracer());
528 ASSERT_TRUE(WaitForWorker());
529 }
530
TEST_F(PtraceResumptionTest,seize_interrupt)531 TEST_F(PtraceResumptionTest, seize_interrupt) {
532 StartTracer([this]() {
533 ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno);
534 ASSERT_EQ(0, ptrace(PTRACE_INTERRUPT, worker, 0, 0)) << strerror(errno);
535 wait_for_ptrace_stop(worker);
536 });
537 ASSERT_TRUE(WaitForTracer());
538 ASSERT_TRUE(WaitForWorker());
539 }
540
TEST_F(PtraceResumptionTest,seize_interrupt_cont)541 TEST_F(PtraceResumptionTest, seize_interrupt_cont) {
542 StartTracer([this]() {
543 ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno);
544 ASSERT_EQ(0, ptrace(PTRACE_INTERRUPT, worker, 0, 0)) << strerror(errno);
545 wait_for_ptrace_stop(worker);
546 ASSERT_EQ(0, ptrace(PTRACE_CONT, worker, 0, 0)) << strerror(errno);
547 });
548 ASSERT_TRUE(WaitForTracer());
549 ASSERT_TRUE(WaitForWorker());
550 }
551
TEST_F(PtraceResumptionTest,zombie_seize)552 TEST_F(PtraceResumptionTest, zombie_seize) {
553 StartTracer([this]() { ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno); });
554 ASSERT_TRUE(WaitForWorker());
555 ASSERT_TRUE(WaitForTracer());
556 }
557
TEST_F(PtraceResumptionTest,zombie_seize_interrupt)558 TEST_F(PtraceResumptionTest, zombie_seize_interrupt) {
559 StartTracer([this]() {
560 ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno);
561 ASSERT_EQ(0, ptrace(PTRACE_INTERRUPT, worker, 0, 0)) << strerror(errno);
562 wait_for_ptrace_stop(worker);
563 });
564 ASSERT_TRUE(WaitForWorker());
565 ASSERT_TRUE(WaitForTracer());
566 }
567
TEST_F(PtraceResumptionTest,zombie_seize_interrupt_cont)568 TEST_F(PtraceResumptionTest, zombie_seize_interrupt_cont) {
569 StartTracer([this]() {
570 ASSERT_EQ(0, ptrace(PTRACE_SEIZE, worker, 0, 0)) << strerror(errno);
571 ASSERT_EQ(0, ptrace(PTRACE_INTERRUPT, worker, 0, 0)) << strerror(errno);
572 wait_for_ptrace_stop(worker);
573 ASSERT_EQ(0, ptrace(PTRACE_CONT, worker, 0, 0)) << strerror(errno);
574 });
575 ASSERT_TRUE(WaitForWorker());
576 ASSERT_TRUE(WaitForTracer());
577 }
578