Commit 332d3c5
committed
ltc: serialize NodeRPC::Send under a mutex to fix RPC-client UAF
NodeRPC holds a single shared m_http_request + m_stream and Send() drove
them with no synchronization. The asio thread_pool worker path
(clean_tracker -> ShareTracker::think -> score -> score-callback ->
NodeRPC::getblockheader -> Send) issues a blocking RPC concurrently with
the main thread's own RPC traffic on the same client.
ASan (firewall-isolated sibling, BuildId 9a12b6bc) caught the resulting
heap-use-after-free: while one thread is mid http::write serializing the
request fields (read_iovec), the other enters Send -> prepare_payload ->
set_content_length_impl -> delete_element and frees the Content-Length
basic_fields element the first thread is still reading. In the non-ASan
build this surfaces as the .157 SEGV-inside-malloc crash-loop during
reorg/clean churn (the heap corruption was the downstream symptom).
Guard the full write+read cycle with a per-client mutex. A single HTTP
connection cannot interleave two request/response pairs anyway, so this
adds no stall beyond what correctness already requires.
Follow-up (separate change): keep think()/score() off the synchronous
RPC-on-pool-thread path entirely (cache header height instead of a live
getblockheader in the score callback).1 parent eafcb49 commit 332d3c5
2 files changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
0 commit comments