Repository navigation
mod_http2: Judge a client RST_STREAM's effect on connection mood once. - #1151
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
nghttp2 reports a single client RST_STREAM to httpd twice: once when the RST_STREAM frame itself is received, and again when nghttp2 then closes the stream because of it. h2_mplx_c1_client_rst() ran its reset_is_acceptable() check both times, and the second call always judged the stream "bad" regardless of what that function actually checks, because by then on_stream_close_cb() had already called h2_stream_rst(), which sets stream->rst_error -- the very first thing reset_is_acceptable() tests. This made the forgiving part of reset_is_acceptable() (a stream that already got a response and sent at least one body chunk is fine to cancel) unreachable in practice: every client cancel that end up in on_stream_close_cb() counted against the connection's "mood", however long it had already behaved. With enough concurrent requests on one HTTP/2 connection getting cancelled this way, such as a browser replacing several server-sent-events tabs, the connection's processing_limit collapses and stalls everything else on it. Track whether a stream's client RST_STREAM has already been judged (h2_stream.client_rst_evaluated) and skip the second evaluation, so only the first call's judgement, made before rst_error was set, counts. A genuinely early or abusive reset is unaffected: it is still judged "bad" exactly once, by the same reset_is_acceptable() checks as before. This is the same bug reported against the archived upstream mod_h2 project (icing/mod_h2#318), introduced into httpd's own modules/http2 by 149f6c7 when on_stream_close_cb()'s own h2_mplx_c1_client_rst() call was added for H2MaxStreamErrors; that upstream issue was never fixed before the repository was archived. PR: 70388
|
Thanks for this ! 👍 I'm the reporter of BZ 70388. Real-world case: Mercure (SSE hub) behind mod_proxy_http, multi-page app, Debian 2.4.71. Each page navigation cancels the EventSource, and with ~12+ tabs all requests on the connection stall. Mercure sends ":\n" right after the headers, so with this fix these cancels should always be judged acceptable. Since this is a regression introduced in 2.4.66, would it be possible to propose it for backport to 2.4.x ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nghttp2 reports a single client RST_STREAM to httpd twice: once when the frame arrives, and again when it then closes the stream because of it. h2_mplx_c1_client_rst() judged both calls, and the second one always found the stream "bad" regardless of whether it had already gotten a response and sent data, because on_stream_close_cb() sets stream->rst_error just before that second call -- the very first thing the judging check tests. That made cancelling a still-running response, the only way to end a server-sent-events or websocket stream, count against the connection the same as abuse, and with enough of them at once (several SSE tabs replaced in a browser, say) the connection's worker limit collapses and stalls everything else on it. This tracks whether a stream's reset has already been judged and skips the second, always-unfair evaluation, so only the first call's verdict, made before rst_error existed, counts; a genuinely early or abusive reset is still judged bad exactly once, same as before. Reproduced on trunk with a real HTTP/2 client and with a new pytest test: a cancelled-after-data SSE-like response no longer lowers the limit, while rapid-fire early cancels still do. This is the same bug reported years ago against the archived upstream mod_h2 project (icing/mod_h2#318) and never fixed there before the repo was archived; it reached httpd's own modules/http2 through 149f6c7 (H2MaxStreamErrors) adding the second call site. https://bz.apache.org/bugzilla/show_bug.cgi?id=70388
[x] This PR does not report or address a security vulnerability
(see SECURITY.md and https://www.apache.org/security/#reporting-a-vulnerability).
[x] Code follows the httpd style guide.
[x] New log messages (level debug or higher) use an empty
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).[x] If the change is user-visible, a
changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).[x] Test cases based on pyhttpd are included where appropriate, in the
test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.