[MG_Remote, MG_IntegrationTest, CI, scripts] (P7): add Ph fuzz arm 1 for malformed control frames

This commit is contained in:
2026-09-23 13:45:00 -04:00
parent 7bb1da73d4
commit 3d7cc9592b
8 changed files with 326 additions and 5 deletions
@@ -2129,6 +2129,20 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
LABELS integration-tcp TIMEOUT 120
ENVIRONMENT "${MGL_ITEST_EVENT_FORFEIT_ENVIRONMENT}")
endif()
# P7 F2: Ph fuzz arm 1 (PLAN-PH-P34B-P7.md §1.1, "gate: fuzz arm 1 malformed control
# frames"). Five malformed control frames - bad identifier, truncated length prefix, oversize
# length, garbage flatbuffer, wrong union type - sent to a live supervisor as a FIRST frame
# (answered by name with no child forked, PH-7 (5)) and inside an established session (the
# session ends with a named line and is not counted as a fault), with a well-formed client
# welcomed after each phase. Same shape as TcpLane.SupervisorProtocolControls: its own supervisor on its own
# port, the lane's resource lock, flatc or SKIP (77) - and CI requires it PASSED by name.
add_test(NAME TcpLane.ControlFrameFuzz COMMAND "${Python3_EXECUTABLE}"
"${CMAKE_SOURCE_DIR}/scripts/ci/ph_fuzz_control_frames.py"
--server "${MGL_ITEST_SPLIT_SERVER_PATH}"
--out "${CMAKE_CURRENT_BINARY_DIR}/tcp-control-frame-fuzz")
set_tests_properties(TcpLane.ControlFrameFuzz PROPERTIES
LABELS integration-tcp TIMEOUT 180 SKIP_RETURN_CODE 77
RESOURCE_LOCK mobilegl-tcp)
# D2: the texture-view opt-in on both TCP lists too, so the three shared GLES split arms
# carry one configuration. See the note over MGL_ITEST_GLES_SPLIT_ENVIRONMENT.
#
+17 -1
View File
@@ -420,6 +420,14 @@ void SendLogAck(void* pointer) {
// below, so an apply thread that the stop wakes inside ReserveEventOrBlock names the
// hangup (PeerGone) rather than the stop (PH-6 fix round).
session.NoteControlStreamEnded();
// Fuzz arm 1, steady state. A bad magic or an over-cap length has already been named
// by the framing latch (Framing.h) as it latched; a clean close is the client's normal
// end and says nothing. The one silent case was a close INSIDE a frame - a truncated
// length prefix or payload - which ended the session exactly like a clean close.
if (result == MOBILEGL_ERR_TRANSPORT_CLOSED && control->BufferedBytes() != 0)
WireLogError("MG_Remote server: control connection closed inside a frame (%llu bytes of it "
"received); ending the session",
static_cast<unsigned long long>(control->BufferedBytes()));
break;
}
// THE FILE IDENTIFIER, ASKED FIRST AND SAID OUT LOUD (P7 wave 0).
@@ -478,7 +486,15 @@ void SendLogAck(void* pointer) {
continue;
}
const auto* operation = envelope->msg_as_SurfaceOp();
if (!operation) break;
if (!operation) {
// Fuzz arm 1, steady state: a well-formed envelope of a type this loop does not take
// (or a SurfaceOp tag with no table behind it) ended the session without a word.
WireLogError("MG_Remote server: control frame of type %u (%s) is not a LogFlush or SurfaceOp "
"(size=%llu); ending the session",
static_cast<unsigned>(envelope->msg_type()), Protocol::EnumNameCtrlMsg(envelope->msg_type()),
static_cast<unsigned long long>(size));
break;
}
Server::SurfaceControlFrame reply{};
(void)ServerApplyWireSurfaceOp(*operation, &reply);
// PH-1 (3): an op that latched (its own bytes, or a record the apply thread was on) is
@@ -777,6 +777,11 @@ namespace MobileGL::MG_Remote::Transport {
return m_reader.PendingMessageSize();
}
std::uint64_t SocketTransport::BufferedBytes() {
std::lock_guard<std::mutex> lock(m_recvMutex);
return m_reader.BufferedBytes();
}
MobileGLResult SocketTransport::ShareFd(int fd, MobileGLByteSpan sideband) {
if (m_tcp || m_auxFd < 0) {
// A link that declared no descriptor passing. Rule G: it does not
@@ -843,6 +848,7 @@ namespace MobileGL::MG_Remote::Transport {
return MOBILEGL_ERR_UNSUPPORTED;
}
std::uint64_t SocketTransport::PeekFrameSize() { return 0; }
std::uint64_t SocketTransport::BufferedBytes() { return 0; }
MobileGLResult SocketTransport::ShareFd(int, MobileGLByteSpan) {
return MOBILEGL_ERR_UNSUPPORTED;
}
@@ -167,6 +167,10 @@ namespace MobileGL::MG_Remote::Transport {
void CloseLocalCopy();
// End requests while retaining the receive side for final diagnostics/EOF.
MobileGLResult ShutdownSend();
// Bytes received but not yet returned as a whole frame. Non-zero after a TRANSPORT_CLOSED
// means the peer closed INSIDE a frame, which the steady-state control loop names (fuzz
// arm 1) rather than treating it as the client's normal end.
std::uint64_t BufferedBytes();
private:
// Pulls whatever the socket has into the reassembler. Returns
+2 -2
View File
@@ -11,8 +11,8 @@
// These are the cheap halves. The end-to-end halves - a live supervisor that must answer every
// malformed first frame by name, fork for nothing it has not authenticated, refuse a silent peer
// at its deadline, cap its pending connections and back an address off - are
// TcpLane.SupervisorProtocolControls (scripts/ci/tcp_supervisor_smoke.py). What is pinned here
// is what
// TcpLane.SupervisorProtocolControls (scripts/ci/tcp_supervisor_smoke.py) and
// TcpLane.ControlFrameFuzz (scripts/ci/ph_fuzz_control_frames.py). What is pinned here is what
// those scripts cannot see from outside: that each malformation lands on the shape it is named
// for (and not merely on SOME refusal), that the assembler never reads a byte past the first
// frame, and the backoff's arithmetic.