8193308: Disallow installing user signal handlers for SIGBUS on OSX

Reviewed-by: stuefe, dholmes
This commit is contained in:
Robin Westberg 2018-02-06 15:48:50 +01:00
parent dd416bbf33
commit 69c57791a4
2 changed files with 19 additions and 4 deletions
src/hotspot/os/bsd
test/jdk/sun/misc

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -51,6 +51,12 @@ JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
case SIGILL:
case SIGSEGV:
#if defined(__APPLE__)
/* On Darwin, memory access errors commonly results in SIGBUS instead
* of SIGSEGV. */
case SIGBUS:
#endif
/* The following signal is used by the VM to dump thread stacks unless
ReduceSignalUsage is set, in which case the user is allowed to set
his own _native_ handler for this signal; thus, in either case,

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -112,7 +112,6 @@ public class SunMiscSignalTest {
Object[][] posixSignals = {
{"HUP", IsSupported.YES, registerXrs, raiseXrs, invokedXrs},
{"QUIT", IsSupported.YES, CanRegister.NO, CanRaise.NO, Invoked.NO},
{"BUS", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
{"USR1", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
{"USR2", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
{"PIPE", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
@ -132,6 +131,14 @@ public class SunMiscSignalTest {
{"SYS", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
};
Object[][] posixNonOSXSignals = {
{"BUS", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
};
Object[][] posixOSXSignals = {
{"BUS", IsSupported.YES, CanRegister.NO, CanRaise.NO, Invoked.NO},
};
Object[][] windowsSignals = {
{"HUP", IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
{"QUIT", IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
@ -155,7 +162,9 @@ public class SunMiscSignalTest {
{"SYS", IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
};
return concatArrays(commonSignals, (Platform.isWindows() ? windowsSignals : posixSignals));
Object[][] combinedPosixSignals = concatArrays(posixSignals,
(Platform.isOSX() ? posixOSXSignals : posixNonOSXSignals));
return concatArrays(commonSignals, (Platform.isWindows() ? windowsSignals : combinedPosixSignals));
}
// Provider of invalid signal names