sm: fix deadlock semantics surrounding mitm installation

This commit is contained in:
Michael Scire 2020-09-07 10:40:43 -07:00
parent fac502aaa3
commit 99b5458539
10 changed files with 62 additions and 3 deletions

View file

@ -27,6 +27,10 @@ namespace ams::sf::hipc {
/* Register the query handle. */
impl::RegisterMitmQueryHandle(query_handle, query_func);
/* Clear future declarations if any, now that our query handler is present. */
R_ABORT_UNLESS(sm::mitm::ClearFutureMitm(service_name));
return ResultSuccess();
}

View file

@ -107,6 +107,10 @@ Result smAtmosphereMitmDeclareFuture(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65006);
}
Result smAtmosphereMitmClearFuture(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65007);
}
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServiceName name) {
struct {
u64 process_id;

View file

@ -26,6 +26,7 @@ void smAtmosphereCloseSession(Service *srv);
Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name);
Result smAtmosphereMitmUninstall(SmServiceName name);
Result smAtmosphereMitmDeclareFuture(SmServiceName name);
Result smAtmosphereMitmClearFuture(SmServiceName name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *info_out, SmServiceName name);
#ifdef __cplusplus

View file

@ -37,6 +37,12 @@ namespace ams::sm::mitm {
});
}
Result ClearFutureMitm(ServiceName name) {
return impl::DoWithUserSession([&]() {
return smAtmosphereMitmClearFuture(impl::ConvertName(name));
});
}
Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name) {
return impl::DoWithMitmAcknowledgementSession([&]() {
return smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast<void *>(out_info), impl::ConvertName(name));