Skip to content

Commit 3627b95

Browse files
Laxify SecureSM to allow creation of the JDK's innocuous threads (#77789)
Co-authored-by: Elastic Machine <[email protected]>
1 parent 4afe1e5 commit 3627b95

File tree

1 file changed

+7
-1
lines changed
  • libs/secure-sm/src/main/java/org/elasticsearch/secure_sm

1 file changed

+7
-1
lines changed

libs/secure-sm/src/main/java/org/elasticsearch/secure_sm/SecureSM.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ private void debugThreadGroups(final ThreadGroup caller, final ThreadGroup targe
154154
private static final Permission MODIFY_THREAD_PERMISSION = new RuntimePermission("modifyThread");
155155
private static final Permission MODIFY_ARBITRARY_THREAD_PERMISSION = new ThreadPermission("modifyArbitraryThread");
156156

157+
// Returns true if the given thread is an instance of the JDK's InnocuousThread.
158+
private static boolean isInnocuousThread(Thread t) {
159+
final Class<?> c = t.getClass();
160+
return c.getModule() == Object.class.getModule() && c.getName().equals("jdk.internal.misc.InnocuousThread");
161+
}
162+
157163
protected void checkThreadAccess(Thread t) {
158164
Objects.requireNonNull(t);
159165

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

167173
if (target == null) {
168174
return; // its a dead thread, do nothing.
169-
} else if (source.parentOf(target) == false) {
175+
} else if (source.parentOf(target) == false && isInnocuousThread(t) == false) {
170176
checkPermission(MODIFY_ARBITRARY_THREAD_PERMISSION);
171177
}
172178
}

0 commit comments

Comments
 (0)