Ticket #581: configure_selinux_exec_protect.patch

File configure_selinux_exec_protect.patch, 1.1 KB (added by markmont, 12 years ago)

Improve config/auto/frames/test_exec_linux_c.in to workaround SELinux/Fedora issues related to PARROT_HAS_EXEC_PROTECT. This patch obsoletes configure_jit_selinux.patch

  • config/auto/frames/test_exec_linux_c.in

     
    77 
    88#include <stdio.h> 
    99#include <stdlib.h> 
     10#include <string.h> 
    1011#include <sys/mman.h> 
    1112#include <limits.h> 
    1213#include <errno.h> 
     
    3637    pf t; 
    3738    char *p; 
    3839    int rc; 
    39     int prot = PROT_READ; 
     40    int prot = PROT_READ | PROT_WRITE; 
    4041 
    4142    if (argc != 2) { 
    4243        fprintf(stderr, "usage: test 0 | 1\n"); 
     
    4546    if (atoi(argv[1])) 
    4647        prot |= PROT_EXEC; 
    4748 
    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 
    4955    memcpy(p, code, sizeof (code)); 
    5056    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     } 
    5757 
    5858    if (t() == 1) 
    5959        puts("ok");