Ticket #581: configure_jit_selinux.patch
File configure_jit_selinux.patch, 1.1 KB (added by markmont, 12 years ago) |
---|
-
config/auto/jit/test_exec_linux_c.in
7 7 8 8 #include <stdio.h> 9 9 #include <stdlib.h> 10 #include <string.h> 10 11 #include <sys/mman.h> 11 12 #include <limits.h> 12 13 #include <errno.h> … … 36 37 pf t; 37 38 char *p; 38 39 int rc; 39 int prot = PROT_READ ;40 int prot = PROT_READ | PROT_WRITE; 40 41 41 42 if (argc != 2) { 42 43 fprintf(stderr, "usage: test 0 | 1\n"); … … 45 46 if (atoi(argv[1])) 46 47 prot |= PROT_EXEC; 47 48 48 p = memalign(PAGE_SIZE, sizeof (code)); 49 p = mmap(NULL, PAGE_SIZE, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); 50 if (!p) { 51 perror("mmap failed\n"); 52 exit(1); 53 } 54 49 55 memcpy(p, code, sizeof (code)); 50 56 t = (pf) p; 51 rc = mprotect(p, PAGE_SIZE, prot);52 if (rc) {53 fprintf(stderr, "p = %p PAGE_SIZE = %d (0x%x)\n", p,54 PAGE_SIZE, PAGE_SIZE);55 perror("failure");56 }57 57 58 58 if (t() == 1) 59 59 puts("ok");