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