control_ng: fix type confusion between socket_t* and websocket_conn* … - #2176
Open
mikemeehan203 wants to merge 1 commit into
Open
mikemeehan203 wants to merge 1 commit into
mikemeehan203 wants to merge 1 commit into
Conversation
…in Homer NG tracing
control_ng_process() computed ng_ctx.local_ep (used only for Homer NG
message tracing, homer-enable-ng) by casting its opaque p1 argument to
socket_t* unconditionally:
.local_ep = p1 ? &(((socket_t*)p1)->local) : NULL,
p1 is not always a socket_t*: control_ng_incoming() (UDP) and
control_stream_readable() (TCP) do pass a real socket_t* there, but
both websocket transports (websocket_ng_process_generic() and
websocket_http_ng_generic() in websocket.c) pass a
struct websocket_conn* instead, since p1 is otherwise only used
opaquely, handed straight to each transport own cb() callback.
Reinterpreting a struct websocket_conn* as a socket_t* and dereferencing
->local produces a garbage-but-non-NULL pointer, which then segfaults
inside homer_send() as soon as it is actually sent to Homer -- reliably
reproducible on any NG-over-websocket connection (wss:// via
--listen-https, or plain ws://) once homer-enable-ng is also on.
Fix: add an explicit local_sock parameter to control_ng_process() (and
control_ng_process_plain(), which must keep an identical signature --
both are invoked polymorphically through the same
__typeof__(control_ng_process) cb in websocket.c) used only to build
local_ep, decoupled from p1. Both websocket call sites pass NULL, since
neither has a real listening socket_t to offer; UDP and TCP pass their
already-existing socket_t* unchanged.
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.
…in Homer NG tracing
control_ng_process() computed ng_ctx.local_ep (used only for Homer NG message tracing, homer-enable-ng) by casting its opaque p1 argument to socket_t* unconditionally:
p1 is not always a socket_t*: control_ng_incoming() (UDP) and control_stream_readable() (TCP) do pass a real socket_t* there, but both websocket transports (websocket_ng_process_generic() and websocket_http_ng_generic() in websocket.c) pass a struct websocket_conn* instead, since p1 is otherwise only used opaquely, handed straight to each transport own cb() callback.
Reinterpreting a struct websocket_conn* as a socket_t* and dereferencing ->local produces a garbage-but-non-NULL pointer, which then segfaults inside homer_send() as soon as it is actually sent to Homer -- reliably reproducible on any NG-over-websocket connection (wss:// via --listen-https, or plain ws://) once homer-enable-ng is also on.
Fix: add an explicit local_sock parameter to control_ng_process() (and control_ng_process_plain(), which must keep an identical signature -- both are invoked polymorphically through the same
typeof(control_ng_process) cb in websocket.c) used only to build local_ep, decoupled from p1. Both websocket call sites pass NULL, since neither has a real listening socket_t to offer; UDP and TCP pass their already-existing socket_t* unchanged.
Reproducible on any NG-over-websocket connection (wss:// via --listen-https, or plain ws://) once homer-enable-ng is also on — 100% reproducible in our deployment as soon as real NG traffic crossed that path.