xref: /openbsd-src/regress/sys/kern/syscall_segment/lib/syscall_library.c (revision 03f38e3c140c3945ca5364dfcc63527564b909a2)
1*03f38e3cSderaadt /*	$OpenBSD: syscall_library.c,v 1.1 2019/12/02 23:04:49 deraadt Exp $	*/
2*03f38e3cSderaadt 
3*03f38e3cSderaadt #include <stdlib.h>
4*03f38e3cSderaadt #include <unistd.h>
5*03f38e3cSderaadt 
6*03f38e3cSderaadt pid_t gadget_getpid();
7*03f38e3cSderaadt 
8*03f38e3cSderaadt int
main(int argc,char * argv[])9*03f38e3cSderaadt main(int argc, char *argv[])
10*03f38e3cSderaadt {
11*03f38e3cSderaadt 	/* get my pid doing using the libc path,
12*03f38e3cSderaadt 	 * then try again with some inline asm
13*03f38e3cSderaadt 	 * if we are not killed, and get the same
14*03f38e3cSderaadt 	 * answer, then the test fails
15*03f38e3cSderaadt 	 */
16*03f38e3cSderaadt 	pid_t pid = getpid();
17*03f38e3cSderaadt 	pid_t pid2 = gadget_getpid();
18*03f38e3cSderaadt 	if (pid == pid2)
19*03f38e3cSderaadt 		return 1;
20*03f38e3cSderaadt 
21*03f38e3cSderaadt 	return 0;
22*03f38e3cSderaadt }
23