[Fix] (Remote): offer inproc no shared images and refuse them on its server

This commit is contained in:
2026-10-10 23:23:36 -04:00
parent 745f59bc3f
commit e4aab8d0bc
10 changed files with 131 additions and 33 deletions
+14
View File
@@ -390,6 +390,9 @@ namespace MobileGL::MG_Remote::Server {
ServerSession* session = ServerSession::Active();
if (session == nullptr) return false;
SI::SessionHolder& holder = session->SharedImageHolder();
// Shared images carry memory between processes. A client in this process has none to
// carry, so it gets none - no platform buffer is ever allocated or imported for it.
const Bool peerIsThisProcess = Transport::PeerIsThisProcess(session->ControlTransport());
const auto fill = [&reply](const SI::Image& image) {
reply.ImageId = image.Id;
reply.Modifier = image.Modifier;
@@ -403,6 +406,10 @@ namespace MobileGL::MG_Remote::Server {
};
switch (op.Op) {
case MG_Pipe::kMGPSharedImageAllocate: {
if (peerIsThisProcess) {
MGLOG_W_ONCE("MG_Remote server: a shared-image allocation was refused: the client is this process");
return false;
}
std::string why;
SI::ImageRef image = SI::Allocate(op.Width, op.Height, op.Format, why);
if (image == nullptr) {
@@ -436,6 +443,13 @@ namespace MobileGL::MG_Remote::Server {
static_cast<unsigned long long>(seq), why.c_str());
return false;
}
if (peerIsThisProcess) {
#if !defined(_WIN32)
::close(fd);
#endif
MGLOG_W_ONCE("MG_Remote server: a dma-buf import was refused: the client is this process");
return false;
}
SI::ImageRef image = SI::Identify(fd, why);
// YUV: the planes and colour hints ride in Damage (MGPImportPlaneWord). A buffer this
// server did not allocate is taken too, through the labelled CPU-copy fallback
+1 -2
View File
@@ -1160,8 +1160,7 @@ namespace MobileGL::MG_Remote::Server {
// stores' own mappings, donated as monolith donates them, and no AHardwareBuffer, import
// or POST is involved. A backend that cannot donate leaves the session on T2 - an
// in-process session never takes the AHardwareBuffer arm below.
const Bool inProcess = m_transport != nullptr &&
Transport::AdoptT0::PeerIsThisProcess(m_transport->Role() == Transport::TransportRole::InProcess);
const Bool inProcess = Transport::PeerIsThisProcess(m_transport);
if (inProcess) {
const MG_Pipe::MGPipeResourceOps* ops = MG_Pipe::MGPipeGetResourceOps();
if (MG_Config::Ipc.AllowAdoptT0 == 0) {