CVE-2026-58984 AI-generated analysis
platform/frameworks/native, libbinder Trusty RPC server (libs/binder/trusty/RpcServerTrusty); plus trusty/lib libtipc (lib/tipc/tipc_srv.c)
Adds a destructor to RpcServerTrusty that tears down its registered TIPC service (new tipc_remove_service in trusty/lib) so the TIPC event loop no longer holds pointers into a freed RpcServerTrusty object.
Root cause
RpcServerTrusty::make registered &srv->mTipcPort (a tipc_port member of the RpcServerTrusty object, whose name field points into the member mPortName) with the TIPC service framework via tipc_add_service. The libtipc contract (tipc_srv.h) says the caller keeps ownership of the port structures and must keep them alive while the service is running. The framework keeps a tipc_port pointer in tipc_port_ctx::cfg and uses it from the event path (port_event_handler_proc -> handle_connect uses port->cfg->name). RpcServerTrusty had no destructor and no way to unregister the service, so after the object was destroyed the service stayed registered in the handle set and the event loop could read the freed port data.
How the fix works
- trusty/lib 6d33ba550f02 (dependency), lib/tipc/tipc_srv.c: renames the private structs port_ctx -> tipc_port_ctx and chan_ctx -> tipc_chan_ctx (including tipc_srv::ports[], tipc_chan_close, handle_connect, port_event_handler_proc, tipc_add_service) so tipc_port_ctx can be forward-declared in the public interface. Rename only.
- trusty/lib 0ba8fd47fed4, lib/tipc/include/lib/tipc/tipc_srv.h and lib/tipc/tipc_srv.c: adds int tipc_remove_service(struct tipc_port_ctx* port). It checks port and port->srv. For every port of the service it removes the handle from the handle set (tipc_hset_remove_entry; on error it logs and continues), closes the handle and sets it to INVALID_IPC_HANDLE. It then closes every active channel in srv->chan_list via tipc_chan_close, then calls free(srv). tipc_add_service_ports (which returns the tipc_port_ctx) already exists in this branch's tipc_srv.h.
- platform/frameworks/native abcd262bcd28, libs/binder/trusty/RpcServerTrusty.cpp RpcServerTrusty::make: switches from tipc_add_service to tipc_add_service_ports(handleSet, &srv->mTipcPort, 1, 0, &kTipcOps, &srv->mTipcPortCtx) so the server keeps the tipc_port_ctx handle.
- libs/binder/trusty/include/binder/RpcServerTrusty.h: declares ~RpcServerTrusty() and a new private member tipc_port_ctx* mTipcPortCtx; the constructor initializes it to nullptr.
- libs/binder/trusty/RpcServerTrusty.cpp RpcServerTrusty::~RpcServerTrusty: if mTipcPortCtx != nullptr, calls tipc_remove_service(mTipcPortCtx). The destructor body runs before the members are destroyed (general platform knowledge), so the port data is still valid while the service is unregistered and its channels are closed.
- libs/binder/trusty/include_mock/lib/tipc/tipc_srv.h: adds a forward declaration of struct tipc_port_ctx and inline stubs for tipc_add_service_ports and tipc_remove_service for mock builds.
Completeness
- Covers the lifetime mismatch for the single port registered by RpcServerTrusty::make. On destruction the port handle is removed from the hset and closed, all channels are closed, and the tipc_srv is freed.
- The destructor's nullptr check on mTipcPortCtx skips teardown for an object that was never registered. Whether it also covers the make() failure path depends on tipc_add_service_ports leaving ports_out unset on failure, which the material does not show.
- tipc_remove_service logs but does not abort if tipc_hset_remove_entry fails; it still closes the handle and frees srv. The destructor ignores the return value of tipc_remove_service.
- RpcServerTrusty gets no explicit stop/unregister API; teardown only happens when the object is destroyed. Other direct users of tipc_add_service (e.g. trusty/user/base/app/acvp/acvp.cpp and the scudo test app, per index search) pass static port structs and are not touched by this fix.
- Whether the destructor can run concurrently with the TIPC event loop on another thread is not addressed by the diff; the material does not show the threading model.
Behavior changes
- Destroying an RpcServerTrusty now closes its TIPC port and disconnects all active client channels (tipc_chan_close on every channel in the service), where before the fix the service stayed registered.
- RpcServerTrusty::make now calls tipc_add_service_ports instead of tipc_add_service and stores the returned tipc_port_ctx.
- libtipc gains a new public function tipc_remove_service(struct tipc_port_ctx*) that returns 0 or ERR_INVALID_ARGS; the private types are renamed to tipc_port_ctx and tipc_chan_ctx.
- The mock tipc_srv.h gains tipc_add_service_ports and tipc_remove_service stubs.
Per major
- Android 14: Not affected per the bulletin (not listed). The resolver reports 6/8 lines of the patched region present at android-security-14.0.0_r31, but the material has no Android 14 fix commit.
- Android 15: Same fix: frameworks/native abcd262bcd28 (make -> tipc_add_service_ports, new destructor, mTipcPortCtx, mock stubs) plus trusty/lib 6d33ba550f02 (rename) and 0ba8fd47fed4 (tipc_remove_service) in android-security-15.0.0_r19.
- Android 16: Same fix: frameworks/native 0dc8a256a159 in android-security-16.0.0_r10. The diff content matches Android 15; only header offsets differ. The material shows no trusty/lib commits for this branch.
- Android 17: Adapted fix: frameworks/native 6f06830966a6 in android-security-17.0.0_r3 adds only the destructor, the mTipcPortCtx(nullptr) initializer and the mock tipc_remove_service stub. The diff does not modify make() or declare mTipcPortCtx, which implies both were already present. The existing mock functions already take tipc_port_ctx*. The constructor takes an extra msgQueueLen parameter.
Unknowns
- Which Trusty applications or code paths actually destroy an RpcServerTrusty while the event loop is running (the trigger scenario behind the Critical EoP rating).
- Whether RpcServerTrusty destruction can happen on a thread other than the TIPC event loop thread, and if so whether tipc_remove_service is safe against concurrent event dispatch.
- What tipc_add_service_ports does to ports_out on failure (the destructor relies on mTipcPortCtx staying nullptr).
- The tipc_add_service_ports implementation on this branch is not included in the material.
- Whether Android 16 and 17 needed equivalent trusty/lib changes (tipc_remove_service); only the Android 15 trusty/lib commits are in the material.