X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/79b9da22a1f4b26279940d285c1bc28ce4e99252..07691282a056c4efea71e1e505527601e8cc166b:/OSX/libsecurity_utilities/lib/machserver.cpp diff --git a/OSX/libsecurity_utilities/lib/machserver.cpp b/OSX/libsecurity_utilities/lib/machserver.cpp index 8f825ba2..30408289 100644 --- a/OSX/libsecurity_utilities/lib/machserver.cpp +++ b/OSX/libsecurity_utilities/lib/machserver.cpp @@ -40,6 +40,8 @@ # include #endif +#define SEC_MACH_AUDIT_TOKEN_PID (5) + namespace Security { namespace MachPlusPlus { @@ -245,6 +247,11 @@ void MachServer::runServerThread(bool doTimeout) bufRequest.msgId() <= MACH_NOTIFY_LAST) { // mach kernel notification message // we assume this is quick, so no thread arbitration here + mach_msg_audit_trailer_t *tlr = bufRequest.auditTrailer(); + if (tlr == NULL || tlr->msgh_audit.val[SEC_MACH_AUDIT_TOKEN_PID] != 0) { + secnotice("machserver", "ignoring invalid notify message"); + continue; + } cdsa_notify_server(bufRequest, bufReply); } else { // normal request message @@ -555,6 +562,9 @@ kern_return_t cdsa_mach_notify_dead_name(mach_port_t, mach_port_name_t port) MachServer::active().notifyDeadName(port); } catch (...) { } + // the act of receiving a dead name notification allocates a dead-name + // right that must be deallocated + mach_port_deallocate(mach_task_self(), port); return KERN_SUCCESS; }