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

This commit is contained in:
swung0x48 committed 2026-09-23 13:45:00 -04:00
1 parent 7bb1da73d4
commit 3d7cc9592b
8 files changed
+326 -5

No files matched your search

+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