Changeset 38187 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Nov 6, 2008, 10:47:44 AM (17 years ago)
Author:
[email protected]
Message:

2008-11-06 Alp Toker <[email protected]>

Reviewed by Cameron Zwarich.

https://bugs.webkit.org/show_bug.cgi?id=22033
[GTK] CTI/Linux r38064 crashes; JIT requires executable memory

Mark pages allocated by the FastMalloc mmap code path executable with
PROT_EXEC. This fixes crashes seen on CPUs and kernels that enforce
non-executable memory (like ExecShield on Fedora Linux) when the JIT
is enabled.

This patch does not resolve the issue on debug builds so affected
developers may still need to pass --disable-jit to configure.

  • wtf/TCSystemAlloc.cpp: (TryMmap): (TryDevMem): (TCMalloc_SystemRelease):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/TCSystemAlloc.cpp

    r37772 r38187  
    5252#include "UnusedParam.h"
    5353
     54#if HAVE(MMAP)
     55static const int cProtFlags = PROT_READ | PROT_WRITE
     56#if ENABLE(CTI) && PLATFORM(GTK)
     57                              | PROT_EXEC
     58#endif
     59                              ;
     60#endif
     61
    5462#ifndef MAP_ANONYMOUS
    5563#define MAP_ANONYMOUS MAP_ANON
     
    171179  }
    172180  void* result = mmap(NULL, size + extra,
    173                       PROT_READ|PROT_WRITE,
     181                      cProtFlags,
    174182                      MAP_PRIVATE|MAP_ANONYMOUS,
    175183                      -1, 0);
     
    303311    return NULL;
    304312  }
    305   void *result = mmap(0, size + extra, PROT_WRITE|PROT_READ,
     313  void *result = mmap(0, size + extra, cProtFlags,
    306314                      MAP_SHARED, physmem_fd, physmem_base);
    307315  if (result == reinterpret_cast<void*>(MAP_FAILED)) {
     
    422430
    423431#if HAVE(MMAP)
    424   void *newAddress = mmap(start, length, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
     432  void *newAddress = mmap(start, length, cProtFlags, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
    425433  UNUSED_PARAM(newAddress);
    426434  // If the mmap failed then that's ok, we just won't return the memory to the system.
Note: See TracChangeset for help on using the changeset viewer.