Changeset 38187 in webkit


Ignore:
Timestamp:
Nov 6, 2008 10:47:44 AM (15 years ago)
Author:
alp@webkit.org
Message:

2008-11-06 Alp Toker <alp@nuanti.com>

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):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r38185 r38187  
     12008-11-06  Alp Toker  <alp@nuanti.com>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=22033
     6        [GTK] CTI/Linux r38064 crashes; JIT requires executable memory
     7
     8        Mark pages allocated by the FastMalloc mmap code path executable with
     9        PROT_EXEC. This fixes crashes seen on CPUs and kernels that enforce
     10        non-executable memory (like ExecShield on Fedora Linux) when the JIT
     11        is enabled.
     12
     13        This patch does not resolve the issue on debug builds so affected
     14        developers may still need to pass --disable-jit to configure.
     15
     16        * wtf/TCSystemAlloc.cpp:
     17        (TryMmap):
     18        (TryDevMem):
     19        (TCMalloc_SystemRelease):
     20
    1212008-11-06  Peter Gal  <galpeter@inf.u-szeged.hu>
    222
  • 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.