Skip to content

Commit

Permalink
Laxify SecureSM to allow creation of the JDK's innocuous threads (ela…
Browse files Browse the repository at this point in the history
…stic#77789)

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
ChrisHegarty and elasticmachine authored Sep 16, 2021
1 parent 4afe1e5 commit 3627b95
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ private void debugThreadGroups(final ThreadGroup caller, final ThreadGroup targe
private static final Permission MODIFY_THREAD_PERMISSION = new RuntimePermission("modifyThread");
private static final Permission MODIFY_ARBITRARY_THREAD_PERMISSION = new ThreadPermission("modifyArbitraryThread");

// Returns true if the given thread is an instance of the JDK's InnocuousThread.
private static boolean isInnocuousThread(Thread t) {
final Class<?> c = t.getClass();
return c.getModule() == Object.class.getModule() && c.getName().equals("jdk.internal.misc.InnocuousThread");
}

protected void checkThreadAccess(Thread t) {
Objects.requireNonNull(t);

Expand All @@ -166,7 +172,7 @@ protected void checkThreadAccess(Thread t) {

if (target == null) {
return; // its a dead thread, do nothing.
} else if (source.parentOf(target) == false) {
} else if (source.parentOf(target) == false && isInnocuousThread(t) == false) {
checkPermission(MODIFY_ARBITRARY_THREAD_PERMISSION);
}
}
Expand Down

0 comments on commit 3627b95

Please sign in to comment.