Commit c23571f
committed
crypto: fix TLSWrap use-after-free on pending write
Two fixes for TLSWrap::Destroy() when called with in-flight writes:
1. Destructor path (GC weak callback): do not call InvokeQueued().
StreamReq::Done() mutates JS objects via v8::Object::Set() and may
allocate on the V8 heap, violating V8's invariant that first-pass
weak callbacks must not trigger heap mutation or nested GC.
2. BIO buffer use-after-free: EncOut() passes pointers from the
enc_out_ BIO internal buffer to the underlying stream's uv_write().
If ssl_.reset() frees the BIO while that write is still in flight,
the pointers become dangling. Use ssl_.release() instead when
write_size_ != 0 so the BIO data stays alive.
Also move RemoveStreamListener() before SSL cleanup so the underlying
stream cannot call back into the destroyed TLSWrap.
Refs: #62393
Made-with: Cursor1 parent 0f68423 commit c23571f
3 files changed
Lines changed: 84 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
442 | 445 | | |
443 | 446 | | |
444 | 447 | | |
| |||
1307 | 1310 | | |
1308 | 1311 | | |
1309 | 1312 | | |
1310 | | - | |
| 1313 | + | |
1311 | 1314 | | |
1312 | 1315 | | |
1313 | 1316 | | |
1314 | | - | |
1315 | | - | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1316 | 1325 | | |
1317 | | - | |
1318 | | - | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
1319 | 1329 | | |
1320 | | - | |
1321 | | - | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
1322 | 1340 | | |
| 1341 | + | |
1323 | 1342 | | |
1324 | 1343 | | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | 1344 | | |
1330 | 1345 | | |
1331 | 1346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments