Commit 24b640e
committed
Fix deadlock in RestrictedSecurity mode caused by JAR verification and checkHashValues()
This commit updates isJarVerifierInStackTrace() to inspect all
thread stacks, resolving the deadlock that occurred in
ProfileParser.checkHashValues().
In the failing scenario, one thread (Thread-1) calls
SecureRandom.getInstance(), which triggers checkHashValues()
in RestrictedSecurity mode. This method attempts to obtain
a MessageDigest from provider OpenJCEPlusFIPS, requiring the
corresponding module to be loaded. However, another thread
(Thread-2) is already holding the loader lock while performing
signature verification for a signed class. Thread-1 is then
blocked waiting for that module to load, while Thread-2 waits
for the MessageDigest initialization to complete, resulting
in a circular deadlock.
Previously, isJarVerifierInStackTrace() only checked the
current thread’s stack to decide whether to skip check hash.
It has now been updated to scan the stack traces of all threads,
but except for the VM service threads, allowing it to detect
active JAR verification in other non-VM threads and prevent
potential cross-thread deadlocks.
Signed-off-by: Tao Liu <[email protected]>1 parent db2cf8e commit 24b640e
3 files changed
+21
-3
lines changedLines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
167 | | - | |
| 169 | + | |
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
174 | 184 | | |
175 | 185 | | |
176 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
1045 | 1052 | | |
1046 | 1053 | | |
1047 | 1054 | | |
| 1055 | + | |
1048 | 1056 | | |
1049 | 1057 | | |
1050 | 1058 | | |
1051 | 1059 | | |
| 1060 | + | |
1052 | 1061 | | |
1053 | 1062 | | |
1054 | 1063 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | 312 | | |
314 | 313 | | |
315 | 314 | | |
| |||
0 commit comments