X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/5ba3f43ea354af8ad55bea84372a2bc834d8757c..527f99514973766e9c0382a4d8550dfb00f54939:/bsd/kern/kern_proc.c diff --git a/bsd/kern/kern_proc.c b/bsd/kern/kern_proc.c index c599a4bc7..249d8c355 100644 --- a/bsd/kern/kern_proc.c +++ b/bsd/kern/kern_proc.c @@ -112,6 +112,10 @@ #include #include +#ifdef CONFIG_32BIT_TELEMETRY +#include +#endif /* CONFIG_32BIT_TELEMETRY */ + #if CONFIG_CSR #include #endif @@ -126,6 +130,10 @@ #include +#ifdef CONFIG_32BIT_TELEMETRY +#define MAX_32BIT_EXEC_SIG_SIZE 160 +#endif /* CONFIG_32BIT_TELEMETRY */ + /* * Structure associated with user cacheing. */ @@ -163,7 +171,9 @@ extern int cs_enforcement_enable; #endif #if CONFIG_COREDUMP /* Name to give to core files */ -#if CONFIG_EMBEDDED +#if defined(XNU_TARGET_OS_BRIDGE) +__XNU_PRIVATE_EXTERN char corefilename[MAXPATHLEN+1] = {"/private/var/internal/%N.core"}; +#elif CONFIG_EMBEDDED __XNU_PRIVATE_EXTERN char corefilename[MAXPATHLEN+1] = {"/private/var/cores/%N.core"}; #else __XNU_PRIVATE_EXTERN char corefilename[MAXPATHLEN+1] = {"/cores/core.%P"}; @@ -1153,7 +1163,7 @@ proc_getexecutablevnode(proc_t p) if (vnode_getwithref(tvp) == 0) { return tvp; } - } + } return NULLVP; } @@ -3429,3 +3439,80 @@ proc_get_uthread_uu_threadlist(void * uthread_v) uthread_t uth = (uthread_t)uthread_v; return (uth != NULL) ? uth->uu_threadlist : NULL; } + +#ifdef CONFIG_32BIT_TELEMETRY +void +proc_log_32bit_telemetry(proc_t p) +{ + /* Gather info */ + char signature_buf[MAX_32BIT_EXEC_SIG_SIZE] = { 0 }; + char * signature_cur_end = &signature_buf[0]; + char * signature_buf_end = &signature_buf[MAX_32BIT_EXEC_SIG_SIZE - 1]; + int bytes_printed = 0; + + const char * teamid = NULL; + const char * identity = NULL; + struct cs_blob * csblob = NULL; + + proc_list_lock(); + + /* + * Get proc name and parent proc name; if the parent execs, we'll get a + * garbled name. + */ + bytes_printed = snprintf(signature_cur_end, + signature_buf_end - signature_cur_end, + "%s,%s,", p->p_name, + (p->p_pptr ? p->p_pptr->p_name : "")); + + if (bytes_printed > 0) { + signature_cur_end += bytes_printed; + } + + proc_list_unlock(); + + /* Get developer info. */ + vnode_t v = proc_getexecutablevnode(p); + + if (v) { + csblob = csvnode_get_blob(v, 0); + + if (csblob) { + teamid = csblob_get_teamid(csblob); + identity = csblob_get_identity(csblob); + } + } + + if (teamid == NULL) { + teamid = ""; + } + + if (identity == NULL) { + identity = ""; + } + + bytes_printed = snprintf(signature_cur_end, + signature_buf_end - signature_cur_end, + "%s,%s", teamid, identity); + + if (bytes_printed > 0) { + signature_cur_end += bytes_printed; + } + + if (v) { + vnode_put(v); + } + + /* + * We may want to rate limit here, although the SUMMARIZE key should + * help us aggregate events in userspace. + */ + + /* Emit log */ + kern_asl_msg(LOG_DEBUG, "messagetracer", 3, + /* 0 */ "com.apple.message.domain", "com.apple.kernel.32bit_exec", + /* 1 */ "com.apple.message.signature", signature_buf, + /* 2 */ "com.apple.message.summarize", "YES", + NULL); +} +#endif /* CONFIG_32BIT_TELEMETRY */