summaryrefslogtreecommitdiff
path: root/regress/sys/uvm/wx_syscall/wx_syscall.c
blob: c067ac849ab779e8f39e318ffbe5c4c1cad81786 (plain)
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
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

int
main()
{
	vaddr_t o = (vaddr_t)flock;
	int psz = getpagesize();

	printf("%llx\n", (long long)flock);
	if (mprotect((void *)(o & ~(psz-1)), psz,
	    PROT_EXEC|PROT_WRITE|PROT_READ) == -1 &&
	    errno == ENOTSUP) {
		printf("mprotect -> ENOTSUP?  Please run from wxallowed filesystem\n");
		exit(0);
	}
	flock(0, 0);

	printf("performing syscall succeeded.  Should have been killed.\n");
}