- recent w^x changes combined with random malloc/mmap exposed a previously

undiscovered bug in the SignatureHandlerLibrary. Code generated at runtime
was put into malloc()'ed memory and later attempted to execute it without
first making it executable with mprotect(). Debugging suggestions and help
from tom@, weingart@, marc@, millert@. Thx!
- make sure linux emulation is on for the build phase. needed if you reboot
after extracting.

okay tom@
This commit is contained in:
kurt 2006-01-18 15:08:16 +00:00
parent 6bdc9827f6
commit 7a27922713
2 changed files with 26 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.9 2006/01/02 03:48:40 kurt Exp $
# $OpenBSD: Makefile,v 1.10 2006/01/18 15:08:16 kurt Exp $
# $FreeBSD: /repoman/r/pcvs/ports/java/jdk14/Makefile,v 1.79 2004/08/18 07:06:03 glewis Exp $
ONLY_FOR_ARCHS= i386
@ -7,8 +7,8 @@ COMMENT= "Java2(TM) Standard Edition Dev Kit v${V}"
COMMENT-jre= "Java2(TM) Standard Edition Runtime Environment v${V}"
V= 1.4.2
DISTNAME= j2sdk-1_4_2
PKGNAME= jdk-${V}p4
PKGNAME-jre= jre-${V}p4
PKGNAME= jdk-${V}p5
PKGNAME-jre= jre-${V}p5
CATEGORIES= devel/jdk java
@ -164,6 +164,9 @@ post-patch:
.endfor
.endif
pre-build:
@${SYSCTL}=1
post-build:
@rm -rf ${JDKIMAGEDIR}/demo/jfc/SwingSet2/resources \
${JDKIMAGEDIR}/demo/plugin/jfc/SwingSet2/resources \

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-hotspot_src_cpu_i486_vm_interpreterRT_i486_cpp,v 1.1 2006/01/18 15:08:16 kurt Exp $
--- hotspot/src/cpu/i486/vm/interpreterRT_i486.cpp.orig Wed Sep 10 21:40:12 2003
+++ hotspot/src/cpu/i486/vm/interpreterRT_i486.cpp Wed Jan 18 09:26:07 2006
@@ -8,6 +8,8 @@
#include "incls/_precompiled.incl"
#include "incls/_interpreterRT_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
#define __ _masm->
@@ -83,6 +85,7 @@ class SignatureHandlerLibrary: public Al
InterpreterRuntime::SignatureHandlerGenerator(method, buffer).generate(fingerprint);
// copy into C-heap allocated memory location
address handler = (address)NEW_C_HEAP_ARRAY(u_char, buffer->code_size());
+ mprotect(handler, buffer->code_size(), PROT_READ|PROT_WRITE|PROT_EXEC);
memcpy(handler, buffer->code_begin(), buffer->code_size());
// debugging suppport
if (PrintSignatureHandlers) {