Commit 97e9f99
committed
fix(profiler): cover all JFR-writing signal handlers in drain
jbachorik review (profiler.cpp:1578): the inflight drain previously only
covered CTimer/CTimerJvmti, so the TOCTOU/UAF this PR closes for those
handlers remains open for the other CPU and wall fallback engines.
Add InflightGuard at signal-handler entry (after the foreign-signal
filter passes, before any JFR-writing code) for:
- PerfEvents::signalHandler (CPU fallback, same risk shape as CTimer)
- ITimer::signalHandler (CPU fallback when timer_create absent)
- ITimerJvmti::signalHandler (CPU + jvmtistacks fallback)
- WallClockASGCT::sharedSignalHandler (default wall handler)
- WallClockJvmti::sharedSignalHandler (wall + jvmtistacks handler)
For the wall handlers the guard is placed in sharedSignalHandler — the
engine-specific inner signalHandler is dispatched from the shared scope,
so a single guard in the dispatcher covers every JFR-touching code path
in both wall variants.
Risk profile (highest to lowest probability of hitting the race in
practice): CTimer / PerfEvents (per-thread streams, ~10ms interval,
N concurrent in-flight handlers) > Wall (signals from the wall pthread,
~reservoir_size concurrent) > ITimer / ITimerJvmti (process-wide
setitimer, single in-flight at a time). All five plug into the same
SignalInflight counter so Profiler::stop() drains them uniformly.1 parent 1e75102 commit 97e9f99
3 files changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
735 | 736 | | |
736 | 737 | | |
737 | 738 | | |
| 739 | + | |
738 | 740 | | |
739 | 741 | | |
740 | 742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
246 | 251 | | |
247 | 252 | | |
248 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
249 | 258 | | |
250 | 259 | | |
251 | 260 | | |
| |||
0 commit comments