Commit f301244
proxygen: clear FilterChain tail_ in release()
Summary:
`FilterChain::release()` hands the chain head to the caller but leaves `tail_`
pointing at the last filter. Heap allocated filters delete themselves as soon as
they read EOM or an error, and `FilterChain::setSource()` routes through `tail_`
whenever a filter was inserted - so a released chain can dereference a freed
filter.
`HTTPSourceReader::read()` releases the chain up front and
`HTTPClient::makeRequestReadResponse()` then calls `reader.setSource(nullptr)`,
which makes any heap allocated filter added via
`HTTPSourceReader::insertFilter()` a use-after-free at the end of every request.
That is the ownership model every `FilterFactory` produces
(`RequestContextFilterFactory`, `StatsFilterUtil`, `CompressionFilterFactory`,
`ClientDecompressionFilterFactory` all `setHeapAllocated()`), so today
`FilterFactory` filters cannot be used with an `HTTPSourceReader` at all. The
existing reader filter users - the redirect handler and the logger - own their
filters as members, which is why this has not fired.
Clearing `tail_` makes a released chain empty, so a later `setSource()` applies
to the head instead of a filter the chain no longer owns. In the normal path
that turns the trailing `setSource(nullptr)` into a no-op, since every filter
has already cleared its own source by then.
Split out of D114432220, which needs this to install `FilterFactory` filters on
an `HTTPSourceReader`.
Reviewed By: hanidamlaj
Differential Revision: D114950502
fbshipit-source-id: e334deb011355f5cae8cb9c38b61f15a3f6599131 parent 094fa45 commit f301244
2 files changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
1269 | 1270 | | |
1270 | 1271 | | |
1271 | 1272 | | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1272 | 1294 | | |
1273 | 1295 | | |
1274 | 1296 | | |
| |||
0 commit comments