Line
Link Here
|
0 |
-- a/src/closures.c |
0 |
++ b/src/closures.c |
Lines 458-486
dlmmap (void *start, size_t length, int
Link Here
|
458 |
printf ("mapping in %zi\n", length); |
458 |
printf ("mapping in %zi\n", length); |
459 |
#endif |
459 |
#endif |
460 |
|
460 |
|
461 |
if (execfd == -1 && !is_selinux_enabled ()) |
461 |
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); |
|
|
462 |
if (ptr != MFAIL || (errno != EPERM && errno != EACCES)) |
462 |
{ |
463 |
{ |
463 |
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); |
464 |
return ptr; |
464 |
|
|
|
465 |
if (ptr != MFAIL || (errno != EPERM && errno != EACCES)) |
466 |
/* Cool, no need to mess with separate segments. */ |
467 |
return ptr; |
468 |
|
469 |
/* If MREMAP_DUP is ever introduced and implemented, try mmap |
470 |
with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with |
471 |
MREMAP_DUP and prot at this point. */ |
472 |
} |
465 |
} |
473 |
|
466 |
else |
474 |
if (execsize == 0 || execfd == -1) |
|
|
475 |
{ |
467 |
{ |
476 |
pthread_mutex_lock (&open_temp_exec_file_mutex); |
468 |
/* Retry without PROT_EXEC. This should work in most cases. */ |
477 |
ptr = dlmmap_locked (start, length, prot, flags, offset); |
469 |
ptr = mmap (start, length, prot, flags, fd, offset); |
478 |
pthread_mutex_unlock (&open_temp_exec_file_mutex); |
470 |
if (ptr != MFAIL || (errno != EPERM && errno != EACCES)) |
479 |
|
471 |
return ptr; |
480 |
return ptr; |
|
|
481 |
} |
472 |
} |
482 |
|
473 |
return MFAIL; |
483 |
return dlmmap_locked (start, length, prot, flags, offset); |
|
|
484 |
} |
474 |
} |
485 |
|
475 |
|
486 |
/* Release memory at the given address, as well as the corresponding |
476 |
/* Release memory at the given address, as well as the corresponding |