Comment 1 for bug 869374

Revision history for this message
Mike Hommey (mh-glandium) wrote :

The following program highlights the problem:

#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/ashmem.h>
#include <unistd.h>
#include <sys/syscall.h>

void set_personality(unsigned int p) {
  syscall(__NR_personality, p);
}

int main() {
  int fd = open("/dev/ashmem", O_RDWR);
  set_personality(0);
  ioctl(fd, ASHMEM_SET_SIZE, 4096);
  ioctl(fd, ASHMEM_SET_PROT_MASK, PROT_READ);
  set_personality(0x0400000 /* READ_IMPLIES_EXEC */);
  if (mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0) == MAP_FAILED)
    return 1;
  return 0;
}