(root)/
strace-6.5/
tests/
printpath-umovestr-undumpable.c
       1  /*
       2   * Force legacy printpath/umovestr using PR_SET_DUMPABLE.
       3   *
       4   * Copyright (c) 2017-2021 Dmitry V. Levin <ldv@strace.io>
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include <stdio.h>
      12  #include <unistd.h>
      13  #include <sys/prctl.h>
      14  
      15  #include "test_ucopy.h"
      16  
      17  int
      18  main(void)
      19  {
      20  	if (!test_process_vm_readv())
      21  		perror_msg_and_skip("process_vm_readv");
      22  
      23  	/*
      24  	 * Clearing dumpable flag disallows process_vm_readv.
      25  	 * If the kernel does not contain commit
      26  	 * 84d77d3f06e7e8dea057d10e8ec77ad71f721be3, then
      27  	 * PTRACE_PEEKDATA remains allowed.
      28  	 */
      29  	if (prctl(PR_SET_DUMPABLE, 0))
      30  		perror_msg_and_skip("PR_SET_DUMPABLE 0");
      31  
      32  	if (!test_ptrace_peekdata())
      33  		perror_msg_and_skip("PTRACE_PEEKDATA");
      34  
      35  	test_printpath(sizeof(long) * 4);
      36  
      37  	puts("+++ exited with 0 +++");
      38  	return 0;
      39  }