Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 457194 | Differences between
and this patch

Collapse All | Expand All

(-)src/closures.c.orig (-9 / +25 lines)
Lines 117-122 Link Here
117
#endif /* HAVE_MNTENT */
117
#endif /* HAVE_MNTENT */
118
#include <sys/param.h>
118
#include <sys/param.h>
119
#include <pthread.h>
119
#include <pthread.h>
120
#include <stdlib.h>
120
121
121
/* We don't want sys/mman.h to be included after we redefine mmap and
122
/* We don't want sys/mman.h to be included after we redefine mmap and
122
   dlmunmap.  */
123
   dlmunmap.  */
Lines 125-131 Link Here
125
126
126
#if FFI_MMAP_EXEC_SELINUX
127
#if FFI_MMAP_EXEC_SELINUX
127
#include <sys/statfs.h>
128
#include <sys/statfs.h>
128
#include <stdlib.h>
129
129
130
static int selinux_enabled = -1;
130
static int selinux_enabled = -1;
131
131
Lines 173-195 Link Here
173
#endif /* !FFI_MMAP_EXEC_SELINUX */
173
#endif /* !FFI_MMAP_EXEC_SELINUX */
174
174
175
/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
175
/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
176
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
176
#define LINE_BUFFER 1024
177
#include <stdlib.h>
178
179
static int emutramp_enabled = -1;
177
static int emutramp_enabled = -1;
180
178
static int pax_emutramp_enable = 0;
181
static int
179
static int
182
emutramp_enabled_check (void)
180
emutramp_enabled_check (void)
183
{
181
{
184
  if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
182
  FILE *f;
185
    return 1;
183
  char first[LINE_BUFFER], second[LINE_BUFFER], conf_line[LINE_BUFFER];
184
  f = fopen ("/proc/self/status", "r");
185
  if (f == NULL)
186
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
187
    pax_emutramp_enable = 1;
188
#else
189
    pax_emutramp_enable = 0;
190
#endif
186
  else
191
  else
187
    return 0;
192
    while (fgets (conf_line, LINE_BUFFER, f)) {
193
      sscanf (conf_line, "%s %s", first, second);
194
      if (!strncmp (first, "PaX:", 4)) {
195
        if (second[1] == 'E')
196
          pax_emutramp_enable = 1;
197
      }
198
    }
199
  fclose(f);
200
  if (pax_emutramp_enable) {
201
    if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
202
      return 1;
203
  }
204
  return 0;
188
}
205
}
189
206
190
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
207
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
191
                               : (emutramp_enabled = emutramp_enabled_check ()))
208
                               : (emutramp_enabled = emutramp_enabled_check ()))
192
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
193
209
194
#elif defined (__CYGWIN__) || defined(__INTERIX)
210
#elif defined (__CYGWIN__) || defined(__INTERIX)
195
211

Return to bug 457194