(root)/
strace-6.5/
tests-mx32/
prctl-syscall-user-dispatch.c
       1  /*
       2   * Check decoding of prctl PR_SET_SYSCALL_USER_DISPATCH operation.
       3   *
       4   * Copyright (c) 2021 The strace developers.
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include "scno.h"
      12  #include <stdio.h>
      13  #include <unistd.h>
      14  #include <linux/prctl.h>
      15  #include <linux/capability.h>
      16  
      17  int
      18  main(void)
      19  {
      20  	long rc;
      21  
      22  	prctl_marker();
      23  
      24  	rc = syscall(__NR_prctl, PR_SET_SYSCALL_USER_DISPATCH,
      25  		     PR_SYS_DISPATCH_ON,
      26  		     (kernel_ulong_t) 0xdeadbeeffacefeedULL, 0, 0);
      27  	printf("prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_ON, %#llx"
      28  	       ", 0, NULL) = %s\n",
      29  	       (unsigned long long) (kernel_ulong_t) 0xdeadbeeffacefeedULL,
      30  	       sprintrc(rc));
      31  
      32  	rc = syscall(__NR_prctl, PR_SET_SYSCALL_USER_DISPATCH,
      33  		     PR_SYS_DISPATCH_OFF | F8ILL_KULONG_MASK, 1, 1, 1);
      34  	printf("prctl(PR_SET_SYSCALL_USER_DISPATCH, %s, 0x1, 0x1, 0x1) = %s\n",
      35  	       F8ILL_KULONG_MASK
      36  		? "0xffffffff00000000 /* PR_SYS_DISPATCH_??? */"
      37  		: "PR_SYS_DISPATCH_OFF",
      38  	       sprintrc(rc));
      39  
      40  	rc = syscall(__NR_prctl, PR_SET_SYSCALL_USER_DISPATCH,
      41  		     PR_SYS_DISPATCH_OFF, 0,
      42  		     (kernel_ulong_t) 0xdeadbeeffacefeeeULL,
      43  		     (kernel_ulong_t) 0xdeadbeeffacefeefULL);
      44  	printf("prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF, 0"
      45  	       ", %#llx, %#llx) = %s\n",
      46  	       (unsigned long long) (kernel_ulong_t) 0xdeadbeeffacefeeeULL,
      47  	       (unsigned long long) (kernel_ulong_t) 0xdeadbeeffacefeefULL,
      48  	       sprintrc(rc));
      49  
      50  	const char dummy = 'a';
      51  	rc = syscall(__NR_prctl, PR_SET_SYSCALL_USER_DISPATCH, 2, 1, 1, &dummy);
      52  	printf("prctl(PR_SET_SYSCALL_USER_DISPATCH"
      53  	       ", 0x2 /* PR_SYS_DISPATCH_??? */, 0x1, 0x1, %p) = %s\n",
      54  	       &dummy, sprintrc(rc));
      55  
      56  	puts("+++ exited with 0 +++");
      57  	return 0;
      58  }